JavaScript implementation of Nabto WebRTC Signaling
npm install -g pnpm
The packages directory contains all packages that is to be deployed to the npm repository. These packages are:
- @nabto/webrtc-signaling-common: The SDK implementations shared by both clients and devices
- @nabto/webrtc-signaling-client: The WebRTC Client SDK
- @nabto/webrtc-signaling-device: The WebRTC Device SDK
- @nabto/webrtc-signaling-util: The utility components that can be used on top of the SDK
The examples directory contains examples using the SDK packages.
Running pnpm install in any package directory, example directory, or the root directory will build everything.
Running pnpm run build from the root directory will also build the examples.
The React Web Demo consists of a Web demo written in typescript/react the purpose of the demo is to showcase how a WebRTC Client and device can be constructed.
When the React Web Demo runs in device mode it sends video and audio. When a client connects to a device it receives the video and audio. Video and audio tracks are added to all WebRTC connections by the device.
The demo contains a chat feature to showcase how WebRTC data channels can be used to send data between the peers. The chat feature works by having the device being a central chat hub. When a client writes a chat message the message is sent to the device which then broadcasts the chat message to all the clients which are connected to the device.
The chat messages has the following json format and is encoded and sent as a string over the data channel:
{
"sender": <string>,
"text": <string>
}
https://jsfiddle.net/d580bkaz/27/
The @nabto/webrtc-signaling-client and @nabto/webrtc-signaling-device can be tested against an integration test server.
The integration tests are tested against an integration test server.
- run the integration test server in ../../integration_test_server
- (Optional the openapi stub is committed to git.) generate openapi type definitions
npx @hey-api/openapi-ts -i http://127.0.0.1:13745/swagger/json -o packages/nabto/webrtc-signaling-client/integration_test/generated/client -c @hey-api/client-fetch
- run the tests
npm run test:i
If the Nabto WebRTC Signaling service openapi definition is available at http://127.0.0.1:3000/documentation/json the openapi generator should be run as follows.
npx @openapitools/[email protected] generate -i http://127.0.0.1:3000/documentation/json -g typescript-fetch -o packages/nabto/webrtc-signaling-client/src/impl/backend
When the code looks appropriate, tag a release in git, a github actions job will create npm packages and upload the packages to npm. The version of the packages will be extracted from the git tag.