https://github.com/matter-in-motion/mm-websockets
Websockets transport
https://github.com/matter-in-motion/mm-websockets
api extension matter-in-motion transport websocket websocket-transport websockets
Last synced: 2 months ago
JSON representation
Websockets transport
- Host: GitHub
- URL: https://github.com/matter-in-motion/mm-websockets
- Owner: matter-in-motion
- License: mit
- Created: 2017-07-25T03:44:41.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-04-26T18:55:17.000Z (about 8 years ago)
- Last Synced: 2025-02-16T03:31:44.652Z (over 1 year ago)
- Topics: api, extension, matter-in-motion, transport, websocket, websocket-transport, websockets
- Language: JavaScript
- Size: 5.86 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Matter In Motion. Websockets transport
[](https://www.npmjs.com/package/mm-websockets)
[](https://www.npmjs.com/package/mm-websockets)
Websocket transport extension for [matter in motion](https://github.com/matter-in-motion/mm) framework
## Usage
[Transport installation instructions](https://github.com/matter-in-motion/mm/blob/master/docs/transports.md)
### Protocol
Websockets from the browser:
```js
const msg = [ , , , ];
const con = new WebSocket('ws://localhost:3000/api');
con.onmessage = function(e) {
const res = JSON.parse(e.data);
console.log(res);
}
con.onopen = function() {
con.send(JSON.stringify(msg));
};
```
## Settings
* __pingInterval__ — number. Ping interval in milliseconds
* __type__ string, 'application/json'. Default type of data, 'application/json' is onlt available option for now.
* __port__ number, if defined creates its own http server and listens `port`, otherwise tries to use [http transport](https://github.com/matter-in-motion/mm-http) server
* serializer — string, serializer name to be used as default for websockets messages instead of default
License: MIT.