diff options
author | yipstanley <stanley_yip@brown.edu> | 2019-02-10 22:09:48 -0500 |
---|---|---|
committer | yipstanley <stanley_yip@brown.edu> | 2019-02-10 22:09:48 -0500 |
commit | 2e930b98726a09e597106d43a6763dd36d038771 (patch) | |
tree | 34f2c1e3a0bf652be571c0259c3087b1d36dac00 /src/Server.tsx | |
parent | 5b55e1b6081393989ca35d2964da9604c2a93802 (diff) |
adsklfa
Diffstat (limited to 'src/Server.tsx')
-rw-r--r-- | src/Server.tsx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Server.tsx b/src/Server.tsx index 04473424a..729dfa873 100644 --- a/src/Server.tsx +++ b/src/Server.tsx @@ -2,10 +2,16 @@ import { Field, FieldWaiting, FIELD_ID, DOC_ID, FIELD_WAITING } from "./fields/F import { Key, KeyStore } from "./fields/Key" import { ObservableMap, computed, action, observable } from "mobx"; import { Document } from "./fields/Document" +import * as OpenSocket from 'socket.io-client'; +import { Utils } from "./Utils"; +import { MessageStore } from "./server/Message"; export class Server { static FieldStore: ObservableMap<FIELD_ID, Field> = new ObservableMap(); static DocumentStore: ObservableMap<DOC_ID, ObservableMap<Key, FIELD_ID>> = new ObservableMap(); + static Socket: SocketIOClient.Socket = OpenSocket("http://localhost:8080") + static GUID: string = Utils.GenerateGuid() + public static ClientFieldsCached: ObservableMap<DOC_ID, Field | FIELD_WAITING> = new ObservableMap(); // 'hack' is here temoporarily for simplicity when debugging things. @@ -87,6 +93,12 @@ export class Server { } @action + static connected(message: string) { + console.log(message) + Server.Socket.emit("id", Server.GUID) + } + + @action static receivedDocument(docid: DOC_ID, fieldlist: ObservableMap<Key, FIELD_ID>) { var cachedDoc = this.cacheField(new Document(docid)); fieldlist!.forEach((field: FIELD_ID, key: Key) => (cachedDoc as Document)._proxies.set(key, field)); @@ -104,3 +116,5 @@ export class Server { doc.fields.set(key, cachedField); } } + +Server.Socket.on(MessageStore.Handshake.Message, Server.connected);
\ No newline at end of file |