freechat/freechat-client/src/types.ts
shockrah 8812ff7198 + text/plain Message sending works now
+ More skeleton code for the caching system

! Ready for rtc on text based message listening which is where heavy caching comes into play
2021-03-20 19:35:38 -07:00

63 lines
1.4 KiB
TypeScript

// Basically here we define various types that are used pretty much everywhere
const MESSAGE_TYPES: Array<String> = [
'text/plain',
'image/png', 'image/jpeg', 'image/jpg',
'application/webm', 'application/mp4',
'application/mp3'
]
export class Message {
id: Number
time: Number
type: String
content: String|null
uid: Number
uname: String
cid: Number
constructor(id: Number, time: Number, content: String, type: String, uid: Number, uname: String, cid: Number) {
this.id = id
this.time = time
this.uid = uid
this.uname = uname
this.cid = cid
this.type = type
// throw away the content if its not of a valid type
if(MESSAGE_TYPES.indexOf(type) < 0) {
this.content = null
} else {
this.content = content
}
}
}
export class Channel {
name: String
type: Number
id: Number
description: String|null
constructor(name: String, type: Number, id: Number, desc: String) {
this.name = name
this.type = type
this.id = id
this.description = desc
}
}
export class ServerConfig {
hostname: String
port: Number
protocol: String
constructor(protocol: String, hostname: String, port: Number) {
this.protocol = protocol
this.hostname = hostname
this.port = port
}
}