neo.mjs 4.0.7 → 4.0.8
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neo.mjs",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.8",
|
|
4
4
|
"description": "The webworkers driven UI framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"neo-jsdoc": "^1.0.1",
|
|
50
50
|
"neo-jsdoc-x": "^1.0.4",
|
|
51
51
|
"postcss": "^8.4.12",
|
|
52
|
-
"sass": "^1.50.
|
|
52
|
+
"sass": "^1.50.1",
|
|
53
53
|
"webpack": "^5.72.0",
|
|
54
54
|
"webpack-cli": "^4.9.2",
|
|
55
55
|
"webpack-dev-server": "4.8.1",
|
|
@@ -57,7 +57,7 @@ class Socket extends Base {
|
|
|
57
57
|
*/
|
|
58
58
|
construct(config) {
|
|
59
59
|
super.construct(config);
|
|
60
|
-
this.
|
|
60
|
+
this.createSocket();
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
@@ -70,7 +70,7 @@ class Socket extends Base {
|
|
|
70
70
|
me.reconnectAttempts++;
|
|
71
71
|
|
|
72
72
|
if (me.reconnectAttempts < me.maxReconnectAttempts) {
|
|
73
|
-
me.
|
|
73
|
+
me.createSocket();
|
|
74
74
|
|
|
75
75
|
callback && me.on('open', {
|
|
76
76
|
callback,
|
|
@@ -89,7 +89,7 @@ class Socket extends Base {
|
|
|
89
89
|
let me = this,
|
|
90
90
|
channel = me.channel;
|
|
91
91
|
|
|
92
|
-
console.
|
|
92
|
+
console.log('WS: Sending message', (channel ? '\nChannel: ' + channel : ''), '\nData:', data);
|
|
93
93
|
|
|
94
94
|
return JSON.stringify(channel ? {channel, data} : data);
|
|
95
95
|
}
|
|
@@ -118,6 +118,29 @@ class Socket extends Base {
|
|
|
118
118
|
return value;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
/**
|
|
122
|
+
* @param {Number} [code] defaults to 1000
|
|
123
|
+
* @param {String} [reason]
|
|
124
|
+
*/
|
|
125
|
+
close(code, reason) {
|
|
126
|
+
this.socket.close(code, reason);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
*
|
|
131
|
+
*/
|
|
132
|
+
createSocket() {
|
|
133
|
+
this.socket = new WebSocket(this.serverAddress);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
*
|
|
138
|
+
*/
|
|
139
|
+
destroy(...args) {
|
|
140
|
+
this.close();
|
|
141
|
+
super.destroy(...args);
|
|
142
|
+
}
|
|
143
|
+
|
|
121
144
|
/**
|
|
122
145
|
* @param {CloseEvent} event The Websocket generated CloseEvent
|
|
123
146
|
* @param {Number} event.code The WebSocket connection close code provided by the server
|
|
@@ -151,10 +174,12 @@ class Socket extends Base {
|
|
|
151
174
|
}
|
|
152
175
|
|
|
153
176
|
/**
|
|
154
|
-
* @param {
|
|
177
|
+
* @param {MessageEvent} event
|
|
155
178
|
*/
|
|
156
179
|
onMessage(event) {
|
|
157
|
-
|
|
180
|
+
let data = JSON.parse(event.data);
|
|
181
|
+
|
|
182
|
+
console.log('onMessage', data);
|
|
158
183
|
}
|
|
159
184
|
|
|
160
185
|
/**
|
|
@@ -167,7 +192,7 @@ class Socket extends Base {
|
|
|
167
192
|
/**
|
|
168
193
|
* @param {Object} data
|
|
169
194
|
*/
|
|
170
|
-
|
|
195
|
+
sendMessage(data) {
|
|
171
196
|
let me = this,
|
|
172
197
|
socket = me.socket,
|
|
173
198
|
d = data;
|