Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bimedia-fr/architect-socket-server
architect socket server plugin
https://github.com/bimedia-fr/architect-socket-server
Last synced: 8 days ago
JSON representation
architect socket server plugin
- Host: GitHub
- URL: https://github.com/bimedia-fr/architect-socket-server
- Owner: bimedia-fr
- License: apache-2.0
- Created: 2016-05-06T19:13:01.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T19:58:06.000Z (about 2 years ago)
- Last Synced: 2024-12-07T20:59:41.542Z (28 days ago)
- Language: JavaScript
- Size: 96.7 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# architect-socket-server
architect socket server plugin### Installation
```sh
npm install --save architect-socket-server
```
### Config Format```js
{
"packagePath": "architect-socket-server",
port: process.env.PORT || 1337,
host: process.env.IP || "0.0.0.0"
}
```### 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-socket-server",
port: process.env.PORT || 1337,
host: process.env.IP || "0.0.0.0"
}];
```
And in your `index.js` :```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;
}
var socketserver = app.getService('socketserver');
socketserver.on('connection', function (conn) {
conn.write('hello');
});
console.log('app ready');
});
```### Options
* port : tcp port to listent to
* host : host to listen to
* socket: unix socket to listen
* interface : network interface name to listen to (must match `os.networkInterfaces`)
* family : interface address family to listen to (with `interface`).