diff options
Diffstat (limited to 'src/server/Message.ts')
-rw-r--r-- | src/server/Message.ts | 91 |
1 files changed, 59 insertions, 32 deletions
diff --git a/src/server/Message.ts b/src/server/Message.ts index 8f0af08bc..03150c841 100644 --- a/src/server/Message.ts +++ b/src/server/Message.ts @@ -1,22 +1,47 @@ -import { Point } from "../pen-gestures/ndollar"; -import { Utils } from "../Utils"; +import * as uuid from 'uuid'; +import { Point } from '../pen-gestures/ndollar'; +function GenerateDeterministicGuid(seed: string): string { + return uuid.v5(seed, uuid.v5.URL); +} +// eslint-disable-next-line @typescript-eslint/no-unused-vars export class Message<T> { private _name: string; private _guid: string; constructor(name: string) { this._name = name; - this._guid = Utils.GenerateDeterministicGuid(name); + this._guid = GenerateDeterministicGuid(name); } - get Name(): string { return this._name; } - get Message(): string { return this._guid; } + get Name(): string { + return this._name; + } + get Message(): string { + return this._guid; + } } export enum Types { - Number, List, Key, Image, Web, Document, Text, Icon, RichText, DocumentReference, - Html, Video, Audio, Ink, PDF, Tuple, Boolean, Script, Templates + Number, + List, + Key, + Image, + Web, + Document, + Text, + Icon, + RichText, + DocumentReference, + Html, + Video, + Audio, + Ink, + PDF, + Tuple, + Boolean, + Script, + Templates, } export interface Transferable { @@ -26,7 +51,9 @@ export interface Transferable { } export enum YoutubeQueryTypes { - Channels, SearchVideo, VideoDetails + Channels, + SearchVideo, + VideoDetails, } export interface YoutubeQueryInput { @@ -45,7 +72,7 @@ export interface Diff extends Reference { export interface GestureContent { readonly points: Array<Point>; - readonly bounds: { right: number, left: number, bottom: number, top: number, width: number, height: number }; + readonly bounds: { right: number; left: number; bottom: number; top: number; width: number; height: number }; readonly width?: string; readonly color?: string; } @@ -73,27 +100,27 @@ export interface RoomMessage { } export namespace MessageStore { - export const Foo = new Message<string>("Foo"); - export const Bar = new Message<string>("Bar"); - export const SetField = new Message<Transferable>("Set Field"); // send Transferable (no reply) - export const GetField = new Message<string>("Get Field"); // send string 'id' get Transferable back - export const GetFields = new Message<string[]>("Get Fields"); // send string[] of 'id' get Transferable[] back - export const GetDocument = new Message<string>("Get Document"); - export const DeleteAll = new Message<any>("Delete All"); - export const ConnectionTerminated = new Message<string>("Connection Terminated"); - - export const GesturePoints = new Message<GestureContent>("Gesture Points"); - export const MobileInkOverlayTrigger = new Message<MobileInkOverlayContent>("Trigger Mobile Ink Overlay"); - export const UpdateMobileInkOverlayPosition = new Message<UpdateMobileInkOverlayPositionContent>("Update Mobile Ink Overlay Position"); - export const MobileDocumentUpload = new Message<MobileDocumentUploadContent>("Upload Document From Mobile"); - - export const GetRefField = new Message<string>("Get Ref Field"); - export const GetRefFields = new Message<string[]>("Get Ref Fields"); - export const UpdateField = new Message<Diff>("Update Ref Field"); - export const CreateField = new Message<Reference>("Create Ref Field"); - export const YoutubeApiQuery = new Message<YoutubeQueryInput>("Youtube Api Query"); - export const DeleteField = new Message<string>("Delete field"); - export const DeleteFields = new Message<string[]>("Delete fields"); - - export const UpdateStats = new Message<string>("updatestats"); + export const Foo = new Message<string>('Foo'); + export const Bar = new Message<string>('Bar'); + export const SetField = new Message<Transferable>('Set Field'); // send Transferable (no reply) + export const GetField = new Message<string>('Get Field'); // send string 'id' get Transferable back + export const GetFields = new Message<string[]>('Get Fields'); // send string[] of 'id' get Transferable[] back + export const GetDocument = new Message<string>('Get Document'); + export const DeleteAll = new Message<any>('Delete All'); + export const ConnectionTerminated = new Message<string>('Connection Terminated'); + + export const GesturePoints = new Message<GestureContent>('Gesture Points'); + export const MobileInkOverlayTrigger = new Message<MobileInkOverlayContent>('Trigger Mobile Ink Overlay'); + export const UpdateMobileInkOverlayPosition = new Message<UpdateMobileInkOverlayPositionContent>('Update Mobile Ink Overlay Position'); + export const MobileDocumentUpload = new Message<MobileDocumentUploadContent>('Upload Document From Mobile'); + + export const GetRefField = new Message<string>('Get Ref Field'); + export const GetRefFields = new Message<string[]>('Get Ref Fields'); + export const UpdateField = new Message<Diff>('Update Ref Field'); + export const CreateField = new Message<Reference>('Create Ref Field'); + export const YoutubeApiQuery = new Message<YoutubeQueryInput>('Youtube Api Query'); + export const DeleteField = new Message<string>('Delete field'); + export const DeleteFields = new Message<string[]>('Delete fields'); + + export const UpdateStats = new Message<string>('updatestats'); } |