Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bimedia-fr/architect-websocket-server
architect websocket server with websocket multiplex suport and routing.
https://github.com/bimedia-fr/architect-websocket-server
Last synced: 8 days ago
JSON representation
architect websocket server with websocket multiplex suport and routing.
- Host: GitHub
- URL: https://github.com/bimedia-fr/architect-websocket-server
- Owner: bimedia-fr
- License: apache-2.0
- Created: 2016-02-08T14:11:40.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-04-17T08:34:12.000Z (over 6 years ago)
- Last Synced: 2024-12-07T20:10:26.064Z (28 days ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 2
- Watchers: 10
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# architect-websocket-server
architect websocket server with websocket multiplex suport and routing.## installing
```sh
npm install architect-websocket-server
```## Config Format
```js
{
"packagePath": "architect-websocket-server",
port: 8080,
host: '0.0.0.0',
prefix: '/api',
channels: ['printer', 'chatroom']
}
```### Usage
Boot [Architect](https://github.com/c9/architect) :
```js
var path = require('path');
var architect = require("architect");var configPath = path.join(__dirname, "config.js");
var config = architect.loadConfig(configPath);architect.createApp(config, function (err, app) {
if (err) {
throw err;
}
console.log("app ready");
});
```Configure Architect with `config.js` :
```js
module.exports = [{
packagePath: "architect-websocket-server",
port: 8080,
host: '0.0.0.0',
channels: ['printer', 'chatroom']
}, './routes'];
```
And register your routes in `./routes/index.js` :```js
module.exports = function setup(options, imports, register) {
var wsserver = imports.wsserver;
router = wsserver.routers.printer;// register routes
router.mount('catalogue', function (req, ws) {
ws.send({message: 'hello, world'});
});
register();
};
// Consume wsserver plugin
module.exports.consumes=['wsserver'];
```### Options
* port : tcp port to listent to
* host : host to listen to
* prefix : http path prefix to which SockJS is mounted.
* channels: a list of channels to create.