Files
smartuniverse/ts/smartuniverse.classes.client.universemessage.ts
T

43 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

2023-07-25 11:33:13 +02:00
import * as plugins from './smartuniverse.plugins.js';
2018-05-28 12:07:25 +02:00
2023-07-25 11:33:13 +02:00
import * as interfaces from './interfaces/index.js';
2018-05-28 12:07:25 +02:00
export class ClientUniverseMessage<T = any> implements interfaces.IUniverseMessage<T> {
2018-05-28 12:07:25 +02:00
// ======
// STATIC
// ======
public static createMessageFromMessageDescriptor<T = any>(messageDescriptor: interfaces.IUniverseMessage<T>) {
const clientuniverseMessage = new ClientUniverseMessage<T>(messageDescriptor);
2019-08-13 18:06:13 +02:00
return clientuniverseMessage;
}
2018-05-28 12:07:25 +02:00
// ========
// INSTANCE
// ========
2019-04-22 09:58:36 +02:00
2019-04-24 23:27:57 +02:00
// properties
2019-04-22 09:58:36 +02:00
public id: string;
public timestamp: number;
public smartTimestamp: plugins.smarttime.TimeStamp;
public messageText: string;
public passphrase: string;
2019-09-10 23:55:20 +02:00
public payload: T;
2019-04-22 09:58:36 +02:00
public targetChannelName: string;
2019-04-11 17:52:01 +02:00
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;
2019-04-24 23:27:57 +02:00
}
2019-08-13 18:16:16 +02:00
/**
* gets json for payload
*/
2019-06-06 23:23:37 +02:00
getAsJsonForPayload() {}
2018-05-28 12:07:25 +02:00
}