make OutgoingMessage interface an abstract class and add setIdentifier
parent
4d6ceac0f2
commit
601d978883
@ -1,3 +1,20 @@
|
|||||||
export interface Message {
|
export abstract class Message {
|
||||||
timestamp: number;
|
public readonly timestamp: number;
|
||||||
|
public identifier: string;
|
||||||
|
|
||||||
|
|
||||||
|
constructor({ timestamp, identifier }: { timestamp: number; identifier: string }) {
|
||||||
|
if (identifier.length === 0) {
|
||||||
|
throw new Error('Cannot set empty identifier');
|
||||||
|
}
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
this.identifier = identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public setIdentifier(identifier: string) {
|
||||||
|
if (identifier.length === 0) {
|
||||||
|
throw new Error('Cannot set empty identifier');
|
||||||
|
}
|
||||||
|
this.identifier = identifier;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue