cgserver 10.1.0 → 10.1.2

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.
@@ -156,7 +156,7 @@ class MongoExt {
156
156
  try {
157
157
  let where = this._convertWhere({ _id: key });
158
158
  let rs = await Core_1.core.safeCall(col.findOneAndUpdate, col, where, { $inc: { id: 1 } }, { upsert: true });
159
- if (rs.id) {
159
+ if (rs && rs.id) {
160
160
  return rs.id + 1;
161
161
  }
162
162
  return 1;
@@ -42,6 +42,9 @@ class IWebSocket {
42
42
  return this._tipKey;
43
43
  }
44
44
  _ws = null;
45
+ get ws() {
46
+ return this._ws;
47
+ }
45
48
  _req = null;
46
49
  _protoType = IProtoFilter_1.EProtoType.Json;
47
50
  _protoFilter = null;
@@ -192,8 +195,21 @@ class IWebSocket {
192
195
  let data = this._onEncode(msg);
193
196
  this._ws.send(data);
194
197
  }
195
- close() {
196
- this._ws.close();
198
+ /**
199
+ * Close the connection. A close frame will be sent to the remote peer indicating
200
+ * that we wish to close the connection, and we will then wait for up to
201
+ * `config.closeTimeout` milliseconds for an acknowledgment from the remote peer
202
+ * before terminating the underlying socket connection.
203
+ */
204
+ close(reasonCode, description) {
205
+ this._ws.close(reasonCode, description);
206
+ }
207
+ /**
208
+ * Send a close frame to the remote peer and immediately close the socket without
209
+ * waiting for a response. This should generally be used only in error conditions.
210
+ */
211
+ drop(reasonCode, description, skipCloseFrame) {
212
+ this._ws.drop(reasonCode, description, skipCloseFrame);
197
213
  }
198
214
  }
199
215
  exports.IWebSocket = IWebSocket;
@@ -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
+ get ws(): ws.connection;
30
31
  protected _req: ws.request;
31
32
  protected _protoType: EProtoType;
32
33
  protected _protoFilter: IProtoFilter;
@@ -60,5 +61,16 @@ export declare class IWebSocket {
60
61
  onClose(reasonCode: number, description: string): void;
61
62
  filterSendMsg(msg: BaseMsg): boolean;
62
63
  send(msg: BaseMsg): void;
63
- close(): void;
64
+ /**
65
+ * Close the connection. A close frame will be sent to the remote peer indicating
66
+ * that we wish to close the connection, and we will then wait for up to
67
+ * `config.closeTimeout` milliseconds for an acknowledgment from the remote peer
68
+ * before terminating the underlying socket connection.
69
+ */
70
+ close(reasonCode?: number, description?: string): void;
71
+ /**
72
+ * Send a close frame to the remote peer and immediately close the socket without
73
+ * waiting for a response. This should generally be used only in error conditions.
74
+ */
75
+ drop(reasonCode?: number, description?: string, skipCloseFrame?: boolean): void;
64
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cgserver",
3
- "version": "10.1.0",
3
+ "version": "10.1.2",
4
4
  "author": "trojan",
5
5
  "type": "commonjs",
6
6
  "description": "free for all.Websocket or Http",