43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import * as plugins from './smartuniverse.plugins.js';
|
|
|
|
import * as interfaces from './interfaces/index.js';
|
|
|
|
export class ClientUniverseMessage<T = any> implements interfaces.IUniverseMessage<T> {
|
|
// ======
|
|
// STATIC
|
|
// ======
|
|
public static createMessageFromMessageDescriptor<T = any>(messageDescriptor: interfaces.IUniverseMessage<T>) {
|
|
const clientuniverseMessage = new ClientUniverseMessage<T>(messageDescriptor);
|
|
return clientuniverseMessage;
|
|
}
|
|
|
|
// ========
|
|
// INSTANCE
|
|
// ========
|
|
|
|
// properties
|
|
public id: string;
|
|
|
|
public timestamp: number;
|
|
public smartTimestamp: plugins.smarttime.TimeStamp;
|
|
public messageText: string;
|
|
public passphrase: string;
|
|
public payload: T;
|
|
public targetChannelName: string;
|
|
|
|
constructor(messageArg: interfaces.IUniverseMessage<T>) {
|
|
this.id = messageArg.id;
|
|
this.timestamp = messageArg.timestamp;
|
|
this.smartTimestamp = new plugins.smarttime.TimeStamp(this.timestamp);
|
|
this.messageText = messageArg.messageText;
|
|
this.passphrase = messageArg.passphrase;
|
|
this.payload = messageArg.payload as T;
|
|
this.targetChannelName = messageArg.targetChannelName;
|
|
}
|
|
|
|
/**
|
|
* gets json for payload
|
|
*/
|
|
getAsJsonForPayload() {}
|
|
}
|