examples/

directory
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2026 License: MIT

README

Chat example

A minimal chat server and client demonstrating the socketio package: broadcast events, rooms, and acknowledgements.

Run

Start the server:

go run ./examples/chat-server

In another terminal, start one or more clients:

go run ./examples/chat-client

Commands

In the client, type a plain line to broadcast a message to everyone, or use:

  • /join <room> / /leave <room> — join or leave a room
  • /room <room> <text> — send a message to a room only
  • /ping — exercise an acknowledgement round-trip

Note that Server.BroadcastToRoom includes the sender, while a socket's own To(room) operator targets everyone in the room except the sender, matching the official socket.io socket.to(room) semantics.

Stop the server to watch the client reconnect (enabled via Reconnection).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL