https://github.com/versatica/jssip-node-websocket
JsSIP.Socket interface for the Node.js based on the websocket module
https://github.com/versatica/jssip-node-websocket
Last synced: 9 months ago
JSON representation
JsSIP.Socket interface for the Node.js based on the websocket module
- Host: GitHub
- URL: https://github.com/versatica/jssip-node-websocket
- Owner: versatica
- Created: 2016-05-30T14:02:44.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-06-12T08:58:03.000Z (over 1 year ago)
- Last Synced: 2025-04-17T01:38:37.882Z (10 months ago)
- Language: JavaScript
- Size: 77.1 KB
- Stars: 19
- Watchers: 4
- Forks: 16
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## jssip-node-websocket
`JsSIP.Socket` interface for Node.js based on the [websocket](https://www.npmjs.com/package/websocket) module.
The aim of this module is to provide [JsSIP](http://jssip.net) with WebSocket support when running in Node.js.
## Installation
```bash
$ npm install jssip-node-websocket --save
```
## Requirements
* [jssip](http://jssip.net) >= `v2.0.0`
* Node.js >= `v4.0.0` < `v20.0.0`
### Node >= `v20.0.0`
Since Node `v20.0.0` the API for parsing URL has changed. To be compatible with Node `v20.0.0` and previous versions you can use the following package:
[@meecode/jssip-node-websocket](https://www.npmjs.com/package/@meecode/jssip-node-websocket)
## Usage
```javascript
const JsSIP = require('jssip');
const NodeWebSocket = require('jssip-node-websocket');
let socket = new NodeWebSocket('wss://foo.example.com');
let ua = new JsSIP.UA(
{
uri : 'sip:alice@example.com',
password : 'xxxxxxxx',
display_name : 'Alice',
sockets : [ socket ]
});
```
## API
The module exports a `NodeWebSocket` class conforming with the `JsSIP.Socket` interface.
### `var socket = new NodeWebSocket(url, [options])`
* `url` (String): The WebSocket URL.
* `options` (Object): An object with fields `origin`, `headers`, `requestOptions` and `clientConfig` matching the same meaning and format of the parameters given to the [websocket.W3CWebSocket](https://github.com/theturtle32/WebSocket-Node/blob/v1.0.23/docs/W3CWebSocket.md) class constructor.
## F.A.Q.
##### How to allow invalid TLS certificates?
```javascript
var socket = new Socket('wss://foo.example.com',
{
origin : 'https://www.example.com',
requestOptions :
{
agent : new https.Agent({ rejectUnauthorized: false })
}
});
```
## Author
Iñaki Baz Castillo ([@ibc](https://github.com/ibc/) at Github)
## License
[ISC](./LICENSE)