Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hrishiksh/flutter_webrtc_websocket
Demonstration of flutter webRTC and websocket implementation.
https://github.com/hrishiksh/flutter_webrtc_websocket
flutter webrtc webrtc-demos webrtc-signaling websocket websocket-client
Last synced: 3 months ago
JSON representation
Demonstration of flutter webRTC and websocket implementation.
- Host: GitHub
- URL: https://github.com/hrishiksh/flutter_webrtc_websocket
- Owner: hrishiksh
- Created: 2022-08-03T09:41:34.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-05T11:49:09.000Z (over 2 years ago)
- Last Synced: 2024-05-17T00:39:24.109Z (9 months ago)
- Topics: flutter, webrtc, webrtc-demos, webrtc-signaling, websocket, websocket-client
- Language: C++
- Homepage:
- Size: 196 KB
- Stars: 11
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# flutter_webrtc_websocket
Demonstration of flutter webRTC and websocket implementation.
For WebRTC, I use [flutter_webrtc](https://pub.dev/packages/flutter_webrtc) and for websocket [web_socket_channel](https://pub.dev/packages/web_socket_channel) is used.
For server websocket, I use nodejs with [ws](https://github.com/websockets/ws) library.
https://user-images.githubusercontent.com/52790353/182588642-975a8187-0343-4757-bb60-5aec3af1afd1.mp4
## Server code
To make your own server run this code with `nodejs`. It create a websocket server in port 8080.
```js
import { WebSocket, WebSocketServer } from "ws";const wss = new WebSocketServer({ port: 8080 });
wss.on("connection", (ws) => {
ws.send('{"event":"connection","data":"connected"}');
ws.on("message", (data, isbinary) => {
// Broadcasting to other client except sender
wss.clients.forEach((client) => {
if (client != ws && client.readyState == WebSocket.OPEN) {
client.send(data, { binary: false });
}
});
});
});
```Read [this article]() to get a good grasp about working of the code.
> **Warning**: I haven't added android and IOS specific code. So this app runs only on web. Please add android persmissions in `android-menifest.xml` file. For more, please see the `flutter_webrtc` getting started guide.