Skip to content

Commit bc9a5da

Browse files
Daniel Balladaeyeon
authored andcommitted
Fix not giving 4th argument to websocket.send function call (#1901)
The arguments are directly accessed in the C code therefore not giving all of them JS side can cause issues. This patch fixes it. Fixes #1897 IoT.js-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
1 parent 0eac759 commit bc9a5da

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

src/js/websocket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ Server.prototype.broadcast = function(msg, options) {
237237
this.onError('Compression is not supported');
238238
}
239239
}
240-
var buff = native.send(msg, binary, mask);
240+
var buff = native.send(msg, binary, mask, compress);
241241

242242
var self = this;
243243
this._netserver._serverHandle.clients.forEach(function each(client) {

test/run_pass/issue/issue-1897.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* Copyright 2019-present Samsung Electronics Co., Ltd. and other contributors
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
var websocket = require('websocket');
17+
var client = new websocket.Websocket();
18+
var client2 = new websocket.Websocket();
19+
var wss = new websocket.Server({port: 8081}, function () {});
20+
21+
client.connect('ws://localhost', 8081, '/', function() {
22+
client2.connect('ws://localhost', 8081, '/');
23+
client2.on('open', function() {
24+
wss.broadcast('a');
25+
// prevent blocking
26+
wss.close();
27+
});
28+
});

test/testsets.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,12 @@
10261026
},
10271027
{
10281028
"name": "issue-1557.js"
1029+
},
1030+
{
1031+
"name": "issue-1897.js",
1032+
"required-modules": [
1033+
"websocket"
1034+
]
10291035
}
10301036
],
10311037
"run_fail": [

0 commit comments

Comments
 (0)