Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getWss(route) returns all wss, but expected only by route wss #16

Closed
breeeew opened this issue Aug 28, 2015 · 2 comments
Closed

getWss(route) returns all wss, but expected only by route wss #16

breeeew opened this issue Aug 28, 2015 · 2 comments

Comments

@breeeew
Copy link

breeeew commented Aug 28, 2015

Case from examples:

var express = require('express');
var expressWs = require('..')

var expressWs = expressWs(express());
var app = expressWs.app;

app.ws('/a', function(ws, req) {
});
var aWss = expressWs.getWss('/a');

app.ws('/b', function(ws, req) {
});

setInterval(function () {
  aWss.clients.forEach(function (client) {
    client.send('hello');
  });
}, 5000);

app.listen(3000)

aWss.clients <-- contains all clients, '/a' and '/b', but expected only '/a' clients.

@breeeew
Copy link
Author

breeeew commented Aug 28, 2015

module.exports = function (app, server) {

 ...

  return {
    app: app,
    getWss: function (route) {
      return wsServer; // WAT?
    }
  };
};

@HenningM
Copy link
Owner

Hi,

This is an incompatibility from v0 to v1, and one of the main reasons I decided to bump the major version number. Version 1 uses just 1 WebSocketServer to allow the routing to happen in express. This allows the use of dynamic parts in the URL (named parameters & regex).

If you rely on having different WebSocketServers for each route then I would recommend that you stick to v0.2.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants