aboutsummaryrefslogtreecommitdiff
path: root/src/server/Message.ts
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-04-03 11:54:37 -0400
committerbob <bcz@cs.brown.edu>2019-04-03 11:54:37 -0400
commit6d327d692a316b7dacbb542950d913a9ca361dbb (patch)
tree11d32c084c2cf83794fc689564caeadae9c996c9 /src/server/Message.ts
parentbb7d5a26ec68f283c5adb42d4d6554253de7176f (diff)
parentbc572b4459455e6b046972b0f984868acc6701b5 (diff)
Merge branch 'minimize' into decor
Diffstat (limited to 'src/server/Message.ts')
-rw-r--r--src/server/Message.ts168
1 files changed, 94 insertions, 74 deletions
diff --git a/src/server/Message.ts b/src/server/Message.ts
index 05ae0f19a..29df57419 100644
--- a/src/server/Message.ts
+++ b/src/server/Message.ts
@@ -1,125 +1,145 @@
import { Utils } from "../Utils";
export class Message<T> {
- private name: string;
- private guid: string;
+ private name: string;
+ private guid: string;
- get Name(): string {
- return this.name;
- }
+ get Name(): string {
+ return this.name;
+ }
- get Message(): string {
- return this.guid
- }
+ get Message(): string {
+ return this.guid;
+ }
- constructor(name: string) {
- this.name = name;
- this.guid = Utils.GenerateDeterministicGuid(name)
- }
+ constructor(name: string) {
+ this.name = name;
+ this.guid = Utils.GenerateDeterministicGuid(name);
+ }
- GetValue() {
- return this.Name;
- }
+ GetValue() {
+ return this.Name;
+ }
}
class TestMessageArgs {
- hello: string = "";
+ hello: string = "";
}
export class SetFieldArgs {
- field: string;
- value: any;
+ field: string;
+ value: any;
- constructor(f: string, v: any) {
- this.field = f
- this.value = v
- }
+ constructor(f: string, v: any) {
+ this.field = f;
+ this.value = v;
+ }
}
export class GetFieldArgs {
- field: string;
+ field: string;
- constructor(f: string) {
- this.field = f
- }
+ constructor(f: string) {
+ this.field = f;
+ }
}
export enum Types {
- Number, List, Key, Image, Web, Document, Text, RichText, DocumentReference, Html, Video, Audio, Ink, PDF, Tuple, HistogramOp
+ Number,
+ List,
+ Key,
+ Image,
+ Web,
+ Document,
+ Text,
+ RichText,
+ DocumentReference,
+ Html,
+ Video,
+ Audio,
+ Ink,
+ PDF,
+ Tuple,
+ HistogramOp,
+ Minimized
}
export class DocumentTransfer implements Transferable {
- readonly type = Types.Document
- _id: string
-
- constructor(readonly obj: { type: Types, data: [string, string][], _id: string }) {
- this._id = obj._id
- }
+ readonly type = Types.Document;
+ _id: string;
+
+ constructor(
+ readonly obj: { type: Types; data: [string, string][]; _id: string }
+ ) {
+ this._id = obj._id;
+ }
}
export class ImageTransfer implements Transferable {
- readonly type = Types.Image
+ readonly type = Types.Image;
- constructor(readonly _id: string) { }
+ 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
- }
+ 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;
+ type = Types.List;
- constructor(readonly _id: string) { }
+ constructor(readonly _id: string) {}
}
export class NumberTransfer implements Transferable {
- readonly type = Types.Number
+ readonly type = Types.Number;
- constructor(readonly value: number, readonly _id: string) { }
+ 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
- }
+ 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
- }
+ value: string;
+ readonly _id: string;
+ readonly type = Types.Text;
+
+ constructor(t: string, i: string) {
+ this.value = t;
+ this._id = i;
+ }
}
export interface Transferable {
- readonly _id: string
- readonly type: Types
+ readonly _id: string;
+ readonly type: Types;
}
export namespace MessageStore {
- export const Foo = new Message<string>("Foo");
- export const Bar = new Message<string>("Bar");
- export const AddDocument = new Message<DocumentTransfer>("Add Document");
- export const SetField = new Message<{ _id: string, data: any, type: Types }>("Set Field")
- export const GetField = new Message<string>("Get Field")
- export const GetFields = new Message<string[]>("Get Fields")
- export const GetDocument = new Message<string>("Get Document");
- export const DeleteAll = new Message<any>("Delete All");
-} \ No newline at end of file
+ export const Foo = new Message<string>("Foo");
+ export const Bar = new Message<string>("Bar");
+ export const AddDocument = new Message<DocumentTransfer>("Add Document");
+ export const SetField = new Message<{ _id: string; data: any; type: Types }>(
+ "Set Field"
+ );
+ export const GetField = new Message<string>("Get Field");
+ export const GetFields = new Message<string[]>("Get Fields");
+ export const GetDocument = new Message<string>("Get Document");
+ export const DeleteAll = new Message<any>("Delete All");
+}