cgserver 8.9.15 → 8.9.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/lib/Framework/SocketServer/ISocketServer.js +3 -3
- package/dist/lib/Framework/SocketServer/IWebSocket.js +3 -1
- package/dist/types/Framework/SocketServer/ISocketServer.d.ts +1 -1
- package/dist/types/Framework/SocketServer/IWebSocket.d.ts +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -149,13 +149,13 @@ class ISocketServer {
|
|
|
149
149
|
}
|
|
150
150
|
Log_1.GLog.info((new Date()) + ' Connection accepted.');
|
|
151
151
|
let server_name = this._getServerNameByCookies(req.cookies);
|
|
152
|
-
this.createWebSocketObjectByProtocol(server_name, conn);
|
|
152
|
+
this.createWebSocketObjectByProtocol(server_name, conn, req);
|
|
153
153
|
}
|
|
154
154
|
catch (e) {
|
|
155
155
|
Log_1.GLog.info(' protocol reject');
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
createWebSocketObjectByProtocol(server_name, _ws) {
|
|
158
|
+
createWebSocketObjectByProtocol(server_name, _ws, req) {
|
|
159
159
|
server_name = server_name || "default";
|
|
160
160
|
let cls = this._name_vs_class[server_name];
|
|
161
161
|
if (!cls) {
|
|
@@ -164,7 +164,7 @@ class ISocketServer {
|
|
|
164
164
|
}
|
|
165
165
|
let ws_server = (new cls(this));
|
|
166
166
|
this.addClient(ws_server);
|
|
167
|
-
ws_server.onConnect(_ws);
|
|
167
|
+
ws_server.onConnect(_ws, req);
|
|
168
168
|
return ws_server;
|
|
169
169
|
}
|
|
170
170
|
_getServerNameByCookies(cookies) {
|
|
@@ -43,6 +43,7 @@ class IWebSocket {
|
|
|
43
43
|
return this._tipKey;
|
|
44
44
|
}
|
|
45
45
|
_ws = null;
|
|
46
|
+
_req = null;
|
|
46
47
|
_protoType = IProtoFilter_1.EProtoType.Json;
|
|
47
48
|
_protoFilter = null;
|
|
48
49
|
_protoPath = "";
|
|
@@ -78,8 +79,9 @@ class IWebSocket {
|
|
|
78
79
|
let msg = this.getNewMsg("heartbeat");
|
|
79
80
|
this.send(msg);
|
|
80
81
|
}
|
|
81
|
-
onConnect(_ws) {
|
|
82
|
+
onConnect(_ws, _req) {
|
|
82
83
|
this._ws = _ws;
|
|
84
|
+
this._req = _req;
|
|
83
85
|
if (!this._protoFilter) {
|
|
84
86
|
this._protoFilter = ProtoFactory_1.GProtoFactory.createFilter(this._protoType);
|
|
85
87
|
this._protoFilter.init(this._protoPath);
|
|
@@ -30,7 +30,7 @@ export declare class ISocketServer {
|
|
|
30
30
|
onClose(connection: ws.connection, reason: number, desc: string): void;
|
|
31
31
|
onListenning(): void;
|
|
32
32
|
onRequest(req: ws.request): void;
|
|
33
|
-
createWebSocketObjectByProtocol(server_name: string, _ws: ws.connection): IClientWebSocket;
|
|
33
|
+
createWebSocketObjectByProtocol(server_name: string, _ws: ws.connection, req: ws.request): IClientWebSocket;
|
|
34
34
|
protected _getServerNameByCookies(cookies: any): string;
|
|
35
35
|
/**
|
|
36
36
|
* 广播消息
|
|
@@ -27,6 +27,7 @@ export declare class IWebSocket {
|
|
|
27
27
|
protected _tipKey: string;
|
|
28
28
|
get tipKey(): string;
|
|
29
29
|
protected _ws: ws.connection;
|
|
30
|
+
protected _req: ws.request;
|
|
30
31
|
protected _protoType: EProtoType;
|
|
31
32
|
protected _protoFilter: IProtoFilter;
|
|
32
33
|
protected _protoPath: string;
|
|
@@ -40,7 +41,7 @@ export declare class IWebSocket {
|
|
|
40
41
|
}): BaseMsg | any;
|
|
41
42
|
receive_heartbeat(jsonData: any): void;
|
|
42
43
|
send_heartbeat(): void;
|
|
43
|
-
onConnect(_ws: ws.connection): void;
|
|
44
|
+
onConnect(_ws: ws.connection, _req: ws.request): void;
|
|
44
45
|
onMessage(message: ws.Message): void;
|
|
45
46
|
protected _onDecode(message: ws.Message, ...params: any[]): any;
|
|
46
47
|
protected _onEncode(data: any, ...params: any[]): any;
|