-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathKBEngine.ts
73 lines (56 loc) · 1.87 KB
/
KBEngine.ts
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
namespace KBEngine
{
export class KBEngineApp
{
public static app: KBEngineApp = undefined;
private networkInterface: NetworkInterface = null;
private args: KBEngineArgs;
private userName: string = "test";
private password: string = "123456";
private clientDatas: Uint8Array = new Uint8Array(0);
private encryptedKey: string = "";
private loginappMessageImported: boolean = false;
private baseappMessageImported: boolean = false;
private serverErrorsDescrImported: boolean = false;
private entitydefImported: boolean = false;
// 登录loginapp的地址
private serverAddress: string = "";
private port: number = 0;
// 服务端分配的baseapp地址
private baseappAddress: string = "";
private baseappPort: number = 0;
private isWss: boolean = false;
private protocol: string = "ws://";
constructor(args: KBEngineArgs)
{
Dbg.ASSERT(KBEngineApp.app === undefined, "KBEngineApp::constructor:singleton KBEngineApp._app must be undefined.");
KBEngineApp.app = this;
this.initialize(args);
}
static getSingleton()
{
if(KBEngineApp.app == undefined)
{
throw new Error("Please create KBEngineApp!");
}
return KBEngineApp.app;
}
public initialize(args: KBEngineArgs): boolean
{
this.args = args;
this.serverAddress = args.address;
this.port = args.port;
this.isWss = args.isWss;
this.protocol = args.isWss ? "wss://" : "ws://";
this.initNetwork();
this.installEvents();
return true;
}
initNetwork(): void
{
}
installEvents(): void
{
}
}
}