@zgfe/business-lib 1.1.29-visual.1 → 1.1.29-visual.3

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.
@@ -31,6 +31,12 @@ export default (function () {
31
31
  client.openLog(true);
32
32
  client.onConnected(onConnected);
33
33
  client.onError(onError);
34
+ client.onLogin(function (res) {
35
+ console.log('onLogin', res);
36
+ });
37
+ client.on('login', function (res) {
38
+ console.log('登录监听1', res);
39
+ });
34
40
  }, [client]);
35
41
  function onConnected() {
36
42
  notification.success({
@@ -9,10 +9,11 @@ declare class SocketClient {
9
9
  private pingTimer?;
10
10
  constructor(url: string, params?: Record<string, any>);
11
11
  emit(event: string, payload: SocketClientTypes.Message['data']['payload']): void;
12
- on(type: string, handle: SocketClientTypes.Handler): void;
12
+ on(type: SocketClientTypes.EventType | string, handle: SocketClientTypes.Handler): void;
13
13
  onConnected(handle: SocketClientTypes.Handler): void;
14
14
  onDisconnected(handle: SocketClientTypes.Handler): void;
15
15
  onError(handle: SocketClientTypes.Handler): void;
16
+ onLogin(handle: SocketClientTypes.Handler): void;
16
17
  private _onError;
17
18
  private _onClose;
18
19
  private _onOpen;
@@ -84,6 +84,11 @@ var SocketClient = /*#__PURE__*/function () {
84
84
  value: function onError(handle) {
85
85
  this.on(SocketClientTypes.EventType.error, handle);
86
86
  }
87
+ }, {
88
+ key: "onLogin",
89
+ value: function onLogin(handle) {
90
+ this.on(SocketClientTypes.EventType.login, handle);
91
+ }
87
92
  }, {
88
93
  key: "_onError",
89
94
  value: function _onError(_event) {
@@ -126,6 +131,7 @@ var SocketClient = /*#__PURE__*/function () {
126
131
  key: "onMessage",
127
132
  value: function onMessage(event) {
128
133
  var res = JSON.parse(event.data);
134
+ if (res.type === SocketClientTypes.RequestType.pong) return;
129
135
  var res_ = res.data;
130
136
  try {
131
137
  res_ = JSON.parse(res.data);
@@ -134,6 +140,9 @@ var SocketClient = /*#__PURE__*/function () {
134
140
  }
135
141
  if (res_.type === SocketClientTypes.RequestType.login) {
136
142
  this.log('info', '登录成功');
143
+ this.listeners[SocketClientTypes.EventType.login].forEach(function (handle) {
144
+ handle.call(undefined, res_);
145
+ });
137
146
  return;
138
147
  }
139
148
  var data = res_.data;
@@ -2,11 +2,13 @@ declare namespace SocketClientTypes {
2
2
  enum EventType {
3
3
  connected = "connected",
4
4
  disconnected = "disconnected",
5
- error = "error"
5
+ error = "error",
6
+ login = "login"
6
7
  }
7
8
  enum RequestType {
8
9
  common = 0,
9
10
  ping = 1,
11
+ pong = 2,
10
12
  login = 3,
11
13
  normal = 5,
12
14
  img = 6
@@ -5,11 +5,13 @@ var SocketClientTypes;
5
5
  EventType["connected"] = "connected";
6
6
  EventType["disconnected"] = "disconnected";
7
7
  EventType["error"] = "error";
8
+ EventType["login"] = "login";
8
9
  })(EventType = SocketClientTypes.EventType || (SocketClientTypes.EventType = {}));
9
10
  var RequestType;
10
11
  (function (RequestType) {
11
12
  RequestType[RequestType["common"] = 0] = "common";
12
13
  RequestType[RequestType["ping"] = 1] = "ping";
14
+ RequestType[RequestType["pong"] = 2] = "pong";
13
15
  RequestType[RequestType["login"] = 3] = "login";
14
16
  RequestType[RequestType["normal"] = 5] = "normal";
15
17
  RequestType[RequestType["img"] = 6] = "img";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.1.29-visual.1",
3
+ "version": "1.1.29-visual.3",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -59,5 +59,5 @@
59
59
  "react": "^16.12.0 || ^17.0.0",
60
60
  "yorkie": "^2.0.0"
61
61
  },
62
- "gitHead": "50cb592d16995908023914177748445ece01c2b0"
62
+ "gitHead": "b9fd435c515e0eab79ed5a696aeb47dc41247d47"
63
63
  }