| title | Socketio | |||||
|---|---|---|---|---|---|---|
| keywords |
|
|||||
| description | A chatroom application using Socket.IO. |
This example demonstrates how to create a simple chatroom using WebSockets. The chatroom supports multiple users and allows them to send messages to each other.
- Go 1.25 or higher
- Go modules
-
Clone the repository:
git clone https://github.com/gofiber/recipes.git cd recipes/socketio-chat -
Install dependencies:
go mod tidy
-
Run the application:
go run main.go
-
The server will start on
http://localhost:3000.
To connect to the WebSocket, use the following URL:
ws://localhost:3000/ws/<user-id>
Here is an example of a message object that can be sent between users:
{
"from": "<user-id>",
"to": "<recipient-user-id>",
"data": "hello"
}