-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
859 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: v2 | ||
plugins: | ||
- local: ./node_modules/ts-proto/protoc-gen-ts_proto | ||
strategy: directory | ||
out: ./packages | ||
opt: | ||
- esModuleInterop=true | ||
- fileSuffix=_pb | ||
inputs: | ||
- directory: ./packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,35 @@ | ||
import { TopologyObject } from "@topology-foundation/object"; | ||
import { newTopologyObject, TopologyObject } from "@topology-foundation/object"; | ||
import { GSet } from "@topology-foundation/crdt"; | ||
|
||
export interface IChat extends TopologyObject { | ||
chat: GSet<string>; | ||
addMessage(timestamp: string, message: string, node_id: string): void; | ||
getMessages(): GSet<string>; | ||
merge(other: Chat): void; | ||
export interface IChat { | ||
cro: TopologyObject; | ||
chat: GSet<string>; | ||
addMessage(timestamp: string, message: string, node_id: string): void; | ||
getMessages(): GSet<string>; | ||
merge(other: Chat): void; | ||
} | ||
|
||
export class Chat extends TopologyObject implements IChat { | ||
// store messages as strings in the format (timestamp, message, peerId) | ||
chat: GSet<string>; | ||
export class Chat implements IChat { | ||
// TODO: Change this to build a TopologyObject with the | ||
// wasm compilation inside and just use the topology object | ||
cro: TopologyObject; | ||
// store messages as strings in the format (timestamp, message, peerId) | ||
chat: GSet<string>; | ||
|
||
constructor(peerId: string) { | ||
super(peerId); | ||
this.chat = new GSet<string>(new Set<string>()); | ||
} | ||
constructor(peerId: string) { | ||
this.cro = newTopologyObject(peerId); | ||
this.chat = new GSet<string>(new Set<string>()); | ||
} | ||
|
||
addMessage(timestamp: string, message: string, node_id: string): void { | ||
this.chat.add(`(${timestamp}, ${message}, ${node_id})`); | ||
} | ||
addMessage(timestamp: string, message: string, node_id: string): void { | ||
this.chat.add(`(${timestamp}, ${message}, ${node_id})`); | ||
} | ||
|
||
getMessages(): GSet<string> { | ||
return this.chat; | ||
} | ||
|
||
merge(other: Chat): void { | ||
this.chat.merge(other.chat); | ||
} | ||
getMessages(): GSet<string> { | ||
return this.chat; | ||
} | ||
|
||
merge(other: Chat): void { | ||
this.chat.merge(other.chat); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { TopologyNetworkNodeConfig, TopologyNetworkNode } from "./node.js"; | ||
export { stringToStream, streamToString } from "./stream.js"; | ||
export * from "./node.js"; | ||
export * from "./stream.js"; | ||
export * from "./proto/messages_pb.js"; |
Oops, something went wrong.