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.
session-desktop/ts/session/messages/outgoing/Message.ts

24 lines
486 B
TypeScript

import { v4 as uuid } from 'uuid';
export interface MessageParams {
timestamp: number;
}
export abstract class Message {
public readonly timestamp: number;
public identifier: string;
constructor({ timestamp }: MessageParams) {
this.timestamp = timestamp;
this.identifier = uuid();
}
public setIdentifier(identifier: string) {
if (identifier.length === 0) {
throw new Error('Cannot set empty identifier');
}
this.identifier = identifier;
}
}