Common stuff initial
This commit is contained in:
parent
e4ed7999de
commit
923c82f832
22
dataTypes.ts
Normal file
22
dataTypes.ts
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
export class Song {
|
||||
public type: SongType
|
||||
public title: string;
|
||||
public url: string;
|
||||
public image: string;
|
||||
public length: number;
|
||||
|
||||
|
||||
constructor(type: SongType, title: string, url: string, image: string, length: number) {
|
||||
this.type = type;
|
||||
this.title = title;
|
||||
this.url = url;
|
||||
this.image = image;
|
||||
this.length = length;
|
||||
}
|
||||
}
|
||||
|
||||
export enum SongType {
|
||||
YouTube,
|
||||
Spotify
|
||||
}
|
||||
57
messageTypes.ts
Normal file
57
messageTypes.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import {Song} from "./dataTypes";
|
||||
|
||||
export type StuenMessages = ListenerLeft | ListenerList | ListenerJoined | SendChatMessage | SearchSong | SearchSongResult | Join;
|
||||
export abstract class StuenMessage {
|
||||
constructor(public type: string) {}
|
||||
}
|
||||
|
||||
export class Join extends StuenMessage {
|
||||
constructor(public name: string) {
|
||||
super('Join');
|
||||
}
|
||||
}
|
||||
export class ListenerJoined extends StuenMessage {
|
||||
constructor(public name: string) {
|
||||
super('ListenerJoined');
|
||||
}
|
||||
}
|
||||
|
||||
export class ListenerLeft extends StuenMessage {
|
||||
constructor(public name: string) {
|
||||
super('ListenerLeft');
|
||||
}
|
||||
}
|
||||
|
||||
export class ListenerList extends StuenMessage {
|
||||
constructor(public names: string[]) {
|
||||
super('ListenerList');
|
||||
}
|
||||
}
|
||||
|
||||
export class SendChatMessage extends StuenMessage {
|
||||
constructor(public message: string) {
|
||||
super('SendChatMessage');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class ChatMessage extends StuenMessage {
|
||||
constructor(public name: string, public message: string) {
|
||||
super('ChatMessage');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class SearchSong extends StuenMessage {
|
||||
constructor(public query: string) {
|
||||
super('SearchSong');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class SearchSongResult extends StuenMessage {
|
||||
constructor(public result: Song[]) {
|
||||
super('SearchSongResult');
|
||||
}
|
||||
}
|
||||
|
||||
6
package.json
Normal file
6
package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "stuen-common",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user