aboutsummaryrefslogtreecommitdiffstats
path: root/src/Client.hx
blob: e44417aeaf111ecb420294b31dd185d38e0fc7bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package;

#if nodejs
import js.npm.ws.WebSocket;
#elseif js
import js.html.WebSocket;
#end

typedef ClientData = {
	name:String,
	isLeader:Bool
}

class Client {

	public final ws:WebSocket;
	public var name:String;
	public var isLeader:Bool;

	public function new(?ws:WebSocket, name:String, isLeader = false) {
		this.ws = ws;
		this.name = name;
		this.isLeader = isLeader;
	}

	public function getData():ClientData {
		return {
			name: name,
			isLeader: isLeader
		}
	}

	public static function fromData(data:ClientData):Client {
		return new Client(data.name, data.isLeader);
	}

}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage