https://github.com/snykk/go-websocket
This repository provides basic WebSocket implementations for learning purposes. It covers foundational concepts, from simple one-to-one communication to multi-client broadcasting
https://github.com/snykk/go-websocket
Last synced: 2 months ago
JSON representation
This repository provides basic WebSocket implementations for learning purposes. It covers foundational concepts, from simple one-to-one communication to multi-client broadcasting
- Host: GitHub
- URL: https://github.com/snykk/go-websocket
- Owner: snykk
- Created: 2024-12-01T10:06:47.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-12-01T11:33:32.000Z (10 months ago)
- Last Synced: 2025-03-29T01:42:09.554Z (7 months ago)
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## WebSocket Implementations: Basic vs Advanced
### Overview
These implementations represent **basic examples** designed for **learning purposes**. They demonstrate foundational WebSocket concepts but lack features like authentication, scalability, and advanced error handling.
---
### Basic WebSocket
- **Purpose**: Simple implementation for one-to-one communication.
- **Key Features**:
- Handles a single client at a time.
- Echoes messages back to the sender.
- Easy to implement, suitable for learning WebSocket basics.
- **Usage**:
- Best for lightweight applications where broadcasting is unnecessary.---
### Advanced WebSocket
- **Purpose**: Introduction to multi-client communication.
- **Key Features**:
- Maintains a list of connected clients.
- Broadcasts messages to all clients.
- Utilizes `sync.Mutex` for thread-safe access to the client registry.
- **Usage**:
- Ideal for chat systems, notifications, or collaborative applications.---
### Simulation Steps
1. **Basic**:
- Run the server and connect with a single client.
- Send messages and observe the server's direct response.
2. **Advanced**:
- Run the server and connect multiple clients.
- Send a message from one client to observe its broadcast to all connected clients.