Skip to content

Commit

Permalink
feat(metadata): add 2 static function mergeTitle and mergeFixData
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricenclos committed Jun 28, 2018
1 parent 6e5e3f7 commit 224e218
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/doc/MetaDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Expand Down

0 comments on commit 224e218

Please sign in to comment.