aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/Message.ts66
-rw-r--r--src/server/index.ts3
2 files changed, 69 insertions, 0 deletions
diff --git a/src/server/Message.ts b/src/server/Message.ts
index 15329249d..44df7be1c 100644
--- a/src/server/Message.ts
+++ b/src/server/Message.ts
@@ -47,6 +47,72 @@ export class GetFieldArgs {
}
}
+export enum Types {
+ Number, List, Key, Image, Document, Text, RichText, DocumentReference
+}
+
+export class DocumentTransfer implements Transferable {
+ readonly type = Types.Document
+
+ constructor(readonly id: string) { }
+}
+
+export class ImageTransfer implements Transferable {
+ readonly type = Types.Image
+
+ constructor(readonly id: string) { }
+}
+
+export class KeyTransfer implements Transferable {
+ name: string
+ readonly id: string
+ readonly type = Types.Key
+
+ constructor(i: string, n: string) {
+ this.name = n
+ this.id = i
+ }
+}
+
+export class ListTransfer implements Transferable {
+ type = Types.List;
+
+ constructor(readonly id: string) { }
+}
+
+export class NumberTransfer implements Transferable {
+ readonly type = Types.Number
+
+ constructor(readonly value: number, readonly id: string) { }
+}
+
+export class TextTransfer implements Transferable {
+ value: string
+ readonly id: string
+ readonly type = Types.Text
+
+ constructor(t: string, i: string) {
+ this.value = t
+ this.id = i
+ }
+}
+
+export class RichTextTransfer implements Transferable {
+ value: string
+ readonly id: string
+ readonly type = Types.Text
+
+ constructor(t: string, i: string) {
+ this.value = t
+ this.id = i
+ }
+}
+
+interface Transferable {
+ readonly id: string
+ readonly type: Types
+}
+
export namespace MessageStore {
export const Foo = new Message("Foo", String);
export const Bar = new Message("Bar", String);
diff --git a/src/server/index.ts b/src/server/index.ts
index 0f2409fbb..f5a0fcfe2 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -10,6 +10,7 @@ import { Socket } from 'socket.io';
import { Utils } from '../Utils';
import { ObservableMap } from 'mobx';
import { FIELD_ID, Field } from '../fields/Field';
+import { Database } from './database';
const config = require('../../webpack.config')
const compiler = webpack(config)
const port = 1050; // default port to listen
@@ -55,6 +56,7 @@ server.on("connection", function (socket: Socket) {
function barReceived(guid: String) {
clients[guid.toString()] = new Client(guid.toString());
+ Database.Instance.print()
}
function addDocument(document: Document) {
@@ -62,6 +64,7 @@ function addDocument(document: Document) {
}
function setField(newValue: SetFieldArgs) {
+ Database.Instance.update(newValue.field, newValue.value)
if (FieldStore.get(newValue.field)) {
FieldStore.get(newValue.field)!.TrySetValue(newValue.value);
}