From 224e218edd7764d9b90cd5e11c015b7a01fc9205 Mon Sep 17 00:00:00 2001 From: Cedric Enclos Date: Thu, 28 Jun 2018 10:27:34 +0200 Subject: [PATCH] feat(metadata): add 2 static function mergeTitle and mergeFixData --- src/doc/MetaDataService.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/doc/MetaDataService.ts b/src/doc/MetaDataService.ts index 8861276..ede67c8 100644 --- a/src/doc/MetaDataService.ts +++ b/src/doc/MetaDataService.ts @@ -4,7 +4,7 @@ import { Disposable } from '../Disposable' import { BroadcastMessage, NetworkMessage, SendRandomlyMessage, SendToMessage } from '../network' import { metadata as proto } from '../proto' import { FixDataService, FixDataState } from './FixDataService' -import { TitleService } from './TitleService' +import { TitleService, TitleState } from './TitleService' export enum MetaDataType { Title, @@ -19,6 +19,20 @@ export interface MetaDataMessage { export class MetaDataService implements Disposable { public static ID: number = 430 + static mergeTitle(t1: TitleState, t2: TitleState): object { + const service = new TitleService(0) + service.initTitle(t1.title, t1.count) + service.handleRemoteTitleState({ count: t2.count, title: t2.title }) + return service.state + } + + static mergeFixData(fd1: FixDataState, fd2: FixDataState): FixDataState { + const service = new FixDataService() + service.init(fd1.creationDate, fd1.key) + service.handleRemoteFixDataState(fd2) + return service.state + } + private titleService: TitleService private fixDataService: FixDataService