-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,997 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#! | ||
"use strict"; | ||
const jsdoc2md = require("jsdoc-to-markdown"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
/* input and output paths */ | ||
const inputFile = path.join(__dirname, "../dist/*.js"); | ||
const outputDir = path.join(__dirname, "../docs"); | ||
|
||
/* get template data */ | ||
const templateData = jsdoc2md.getTemplateDataSync({ files: inputFile }); | ||
|
||
/* reduce templateData to an array of class names */ | ||
const classNames = templateData.reduce((names, identifier) => { | ||
if (identifier.kind === "class") names.push(identifier.name); | ||
return names; | ||
}, []); | ||
|
||
/* create a documentation file for each class */ | ||
for (const className of classNames) { | ||
// Workaround an issue with the inputFile picking up wrong classes | ||
if (["Scanner", "Walker", "Parser", "Filter"].includes(className)) continue; | ||
const template = `{{#class name="${className}"}}{{>docs}}{{/class}}`; | ||
console.log(`rendering ${className}, template: ${template}`); | ||
const output = jsdoc2md.renderSync({ | ||
data: templateData, | ||
template: template | ||
}); | ||
fs.writeFileSync(path.resolve(outputDir, `${className}.md`), output); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,153 @@ | ||
# WPhone | ||
<a name="WPhone"></a> | ||
|
||
The very begining of Fonoster WPhone. | ||
## WPhone | ||
WPhone is a basic SIP useragent you can use to create web based softphones. | ||
It uses [SIP.js](sipjs.com) as the foundation, but aims to be much easier for simple uses-cases. | ||
|
||
Usage: | ||
Simply create an HTMLAudioElement, in your html code, give it an `id` and use it to create your WPhone object. | ||
See `src/examples.ts` for an implementation example. | ||
|
||
```bash | ||
git clone https://github.com/fonoster/wphone | ||
cd wphone | ||
npm i | ||
npm run build | ||
npm run start:unsecured | ||
> Thanks to the folks at [onsip.com](onsip.com) for such an amazing job with SIP.js | ||
**Kind**: global class | ||
|
||
* [WPhone](#WPhone) | ||
* [new WPhone(config)](#new_WPhone_new) | ||
* [.call(request)](#WPhone+call) | ||
* [.hangup()](#WPhone+hangup) | ||
* [.connect(register)](#WPhone+connect) | ||
* [.reconnect()](#WPhone+reconnect) | ||
* [.disconnect()](#WPhone+disconnect) | ||
* [.isConnected()](#WPhone+isConnected) | ||
* [.sendDtmf(tones)](#WPhone+sendDtmf) | ||
* [.sendMessage(request)](#WPhone+sendMessage) | ||
* [.on()](#WPhone+on) | ||
|
||
<a name="new_WPhone_new"></a> | ||
|
||
### new WPhone(config) | ||
Constructs a new WPhone object. | ||
|
||
|
||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| config | <code>WPhoneConfig</code> | Configuration object for WPhone | | ||
| config.displayName | <code>string</code> | Optional friendly name to send to the receiver endpoint | | ||
| config.domain | <code>string</code> | Domain or host for the user agent account | | ||
| config.username | <code>string</code> | Username for authentication | | ||
| config.secret | <code>string</code> | Password for authentication | | ||
| config.server | <code>string</code> | Signaling server | | ||
| config.audioElementId | <code>string</code> | HTML element to connect the audio to | | ||
| config.extraHeaders | <code>Array.<string></code> | Optional headers | | ||
| config.expires | <code>string</code> | Expiration for register requests | | ||
|
||
**Example** | ||
```js | ||
const WPhone = require("wphone"); | ||
|
||
const wpconfig = { | ||
displayName: "John Doe", | ||
domain: "sip.acme.com", | ||
username: "john", | ||
secret: "changeit" | ||
audioElementId: "remoteAudio", | ||
secret: "ws://yoursignalingserver:5062" | ||
extraHeaders: ["X-Extra-Header: 'extra header'"] | ||
} | ||
|
||
phone = new WPhone(wpconfig); | ||
await phone.connect(); | ||
await phone.call({ | ||
targetAOR: "sip:1001@sip.domain.net", | ||
extraHeaders: ["X-Extra-Header: 'more extra headers'"] | ||
}); | ||
``` | ||
<a name="WPhone+call"></a> | ||
|
||
### wPhone.call(request) | ||
Calls another SIP endpoint. | ||
|
||
**Kind**: instance method of [<code>WPhone</code>](#WPhone) | ||
|
||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| request | <code>CallRequest</code> | Request for SIP invite | | ||
| request.targetAOR | <code>string</code> | Address of Record of receiving endpoint | | ||
| request.extraHeaders | <code>Array.<string></code> | Optional headers | | ||
|
||
**Example** | ||
```js | ||
await phone.connect(); | ||
await phone.call({ | ||
targetAOR: "sip:1001@sip.domain.net" | ||
}); | ||
``` | ||
<a name="WPhone+hangup"></a> | ||
|
||
### wPhone.hangup() | ||
Closes the session. | ||
|
||
**Kind**: instance method of [<code>WPhone</code>](#WPhone) | ||
<a name="WPhone+connect"></a> | ||
|
||
### wPhone.connect(register) | ||
Connects to signaling server and optionally register too. | ||
|
||
**Kind**: instance method of [<code>WPhone</code>](#WPhone) | ||
|
||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| register | <code>boolean</code> | <code>false</code> | If set to `true` it will also register the endpoint | | ||
|
||
<a name="WPhone+reconnect"></a> | ||
|
||
### wPhone.reconnect() | ||
Reconnects to signaling server. | ||
|
||
**Kind**: instance method of [<code>WPhone</code>](#WPhone) | ||
<a name="WPhone+disconnect"></a> | ||
|
||
### wPhone.disconnect() | ||
Closes connection to signaling server. | ||
|
||
**Kind**: instance method of [<code>WPhone</code>](#WPhone) | ||
<a name="WPhone+isConnected"></a> | ||
|
||
### wPhone.isConnected() | ||
Returns `true` if the wphone is connected to WS or WSS server. | ||
|
||
**Kind**: instance method of [<code>WPhone</code>](#WPhone) | ||
<a name="WPhone+sendDtmf"></a> | ||
|
||
### wPhone.sendDtmf(tones) | ||
Sends a DTMF tones to another SIP endpoint. | ||
|
||
**Kind**: instance method of [<code>WPhone</code>](#WPhone) | ||
|
||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| tones | <code>string</code> | Tones to send | | ||
|
||
<a name="WPhone+sendMessage"></a> | ||
|
||
### wPhone.sendMessage(request) | ||
Sends a SIP message to another SIP endpoint. | ||
|
||
**Kind**: instance method of [<code>WPhone</code>](#WPhone) | ||
|
||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| request | <code>MessageRequest</code> | Request to send SIP message | | ||
|
||
<a name="WPhone+on"></a> | ||
|
||
### wPhone.on() | ||
Fires user agents events. | ||
Events: | ||
- invite | ||
- message | ||
- hangup | ||
- error | ||
- disconnect | ||
|
||
**Kind**: instance method of [<code>WPhone</code>](#WPhone) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.