You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
656 B
30 lines
656 B
6 years ago
|
export enum AnalyticsMessageMethod {
|
||
|
TASK = 'TASK',
|
||
|
PING = 'PING',
|
||
|
TASK_RESULT = 'TASK_RESULT'
|
||
|
}
|
||
|
|
||
|
export class AnalyticsMessage {
|
||
|
public constructor(
|
||
|
public method: AnalyticsMessageMethod,
|
||
|
public payload?: string,
|
||
|
public requestId?: number
|
||
|
) {
|
||
|
|
||
|
}
|
||
|
|
||
|
public toObject() {
|
||
|
return {
|
||
|
method: this.method,
|
||
|
payload: this.payload,
|
||
|
requestId: this.requestId
|
||
|
};
|
||
|
}
|
||
|
|
||
|
static fromObject(obj: any): AnalyticsMessage {
|
||
|
if(obj.method === undefined) {
|
||
|
throw new Error('No method in obj:' + obj);
|
||
|
}
|
||
|
return new AnalyticsMessage(obj.method, obj.payload, obj.requestId);
|
||
|
}
|
||
|
}
|