Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cristipufu/peerjs-server-net
ASP.NET Core Server for the PeerJS library which simplifies peer-to-peer data, video, and audio calls.
https://github.com/cristipufu/peerjs-server-net
aspnet-core peerjs peerjs-server webrtc webrtc-demos webrtc-experiments webrtc-signaling websocket-server websockets
Last synced: 10 days ago
JSON representation
ASP.NET Core Server for the PeerJS library which simplifies peer-to-peer data, video, and audio calls.
- Host: GitHub
- URL: https://github.com/cristipufu/peerjs-server-net
- Owner: cristipufu
- License: mit
- Created: 2020-04-05T08:04:25.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-03-12T11:08:38.000Z (over 2 years ago)
- Last Synced: 2024-10-12T18:24:02.608Z (26 days ago)
- Topics: aspnet-core, peerjs, peerjs-server, webrtc, webrtc-demos, webrtc-experiments, webrtc-signaling, websocket-server, websockets
- Language: C#
- Homepage:
- Size: 658 KB
- Stars: 31
- Watchers: 6
- Forks: 12
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# peerjs-server.net
ASP.NET Core Server for the [PeerJS library](https://peerjs.com/) which simplifies peer-to-peer data, video, and audio calls.
To broker connections, PeerJS connects to a PeerServer. Note that no peer-to-peer data goes through the server; The server acts only as a connection broker.
This is an ASP.NET Core port of the [Node.js implementation](https://github.com/peers/peerjs-server).
## Server setup
```C#
public void ConfigureServices(IServiceCollection services)
{
...
// register PeerJs Server dependencies
services.AddPeerJsServer();
}public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
...
// enable PeerJs Server middleware
app.UsePeerJsServer();
}
```That's it, we're good to go.
## Client library setup
The repository also contains a demo project.
However, we can read more about the library usage on the [official website](https://peerjs.com/docs.html). Here's a quick sample:
Add the PeerJS client library to your webpage:
```html```
Create the Peer object:
```js
const peer = new Peer(randomId, {
host: 'localhost',
port: 44329,
path: '/'
});
```Start a call:
```js
// Call a peer, providing our mediaStream
navigator.mediaDevices
.getUserMedia({
audio: true,
video: true
})
.then(function (mediaStream) {
myVideo.srcObject = mediaStream;
// Call a peer, providing our mediaStream
var call = peer.call('dest-peer-id', mediaStream);
});
```Answer call:
```js
peer.on('call', function(call) {
// Answer the call, providing our mediaStream
call.answer(mediaStream);
});
```Use the stream:
```js
call.on('stream', function(stream) {
// `stream` is the MediaStream of the remote peer.
// Here you'd add it to an HTML video/canvas element.
});
```