Implemented support for Websocket Subprotocols in WS Client Node.

This commit is contained in:
Tobias Oort
2022-01-08 21:12:59 +01:00
parent 7cd3e49f04
commit bd77d7eec3
10 changed files with 46 additions and 10 deletions

View File

@@ -366,6 +366,18 @@ describe('websocket Node', function() {
});
});
it('should handle protocol property', function(done) {
var flow = [
{ id: "server", type: "websocket-listener", path: "/ws" },
{ id: "n1", type: "websocket-client", path: getWsUrl("/ws") },
{ id: "n2", type: "websocket-client", path: getWsUrl("/ws"), subprotocol: "testprotocol" }];
helper.load(websocketNode, flow, function() {
helper.getNode("n1").should.have.property("protocol", undefined);
helper.getNode("n2").should.have.property("protocol", "testprotocol");
done();
});
});
it('should connect to server', function(done) {
var flow = [
{ id: "server", type: "websocket-listener", path: "/ws" },
@@ -378,6 +390,18 @@ describe('websocket Node', function() {
});
});
it('should initiate with subprotocol', function(done) {
var flow = [
{ id: "server", type: "websocket-listener", path: "/ws" },
{ id: "n2", type: "websocket-client", path: getWsUrl("/ws"), subprotocol: "testprotocol" }];
helper.load(websocketNode, flow, function() {
getSocket('server').on('connection', function (sock) {
sock.should.have.property("protocol", "testprotocol")
done();
});
});
});
it('should close on delete', function(done) {
var flow = [
{ id: "server", type: "websocket-listener", path: "/ws" },