You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
532 B
TypeScript
21 lines
532 B
TypeScript
export abstract class Message {
|
|
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;
|
|
}
|
|
}
|