A basic websocket-based signaling server written in Go, designed to facilitate peer-to-peer communication in a mesh network. This server helps WebRTC peers discover each other, exchange session descriptions (SDP), and handle ICE candidates. It can be used in projects requiring direct browser-to-browser communication without relying on central media servers.
This signaling server implements basic signaling functionalities required for WebRTC mesh communication, including:
- Peer discovery and connection management.
- Exchanging SDP offers and answers.
- ICE candidate exchange for NAT traversal.
The server supports multiple clients and enables them to connect and communicate directly. It works by passing signaling messages between peers and can handle client disconnections.
- Peer-to-peer WebRTC communication in a full mesh topology.
- Supports WebSocket-based signaling for real-time messaging.
- Allows appending of sender IDs in messages for better traceability.
- Optional logging of peer connections and interactions.
- Graceful handling of peer disconnects and connection cleanup.
- Real-time Communication: Use the server as the foundation for building WebRTC-based real-time communication applications such as video calls, audio calls, or file sharing.
- Mesh Networks: Suitable for decentralized, mesh-style networks where peers directly communicate without the need for a central server.
- Collaborative Tools: Perfect for applications that require direct communication between users, such as collaborative whiteboards or document editing.
To use this signaling server, follow the steps below:
Ensure you have the following installed:
- Go 1.18 or higher
- Gorilla WebSocket for WebSocket handling
- A WebSocket client (browser, or custom client in your application)
To install the Gorilla WebSocket package, run:
go get github.com/gorilla/websocket
-
Clone the repository:
git clone https://github.com/yourusername/webrtc-signaling-server.git cd webrtc-signaling-server
-
Install the dependencies:
go mod tidy
-
Build and run the server:
go run main.go