// Basically here we define various types that are used pretty much everywhere

export class Message {
    private TYPES: Array<String> = ['text', 'jpeg', 'png', 'webm', 'mp4']
    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(this.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
    }
}


