How koioio/communite_room works
Communicate Room is a browser-based, multi-user chat application. Users connect to the Go server over WebSocket, log in, exchange broadcast messages, and receive presence updates; the Hub tracks connections and distributes outbound messages through per-connection queues. The README documents these stages and the concurrency model. Frontend component wiring is supported by sampled Vue source; backend registration, reader/writer routines, and queue behavior are documented, though not all routine implementations were sampled.
Main entry points: ChatRoom.vue Chat room · ws_handler.go WebSocket handler · Hub_Instance.go Hub instance · Hub_logic.go Hub event loop
Components 18
Chat interface
- Vue app
front/chat-app/src/App.vue - Chat room
front/chat-app/src/components/ChatRoom.vue - Online users
front/chat-app/src/components/UserList.vue - Message display
front/chat-app/src/components/MessageList.vue
HTTP and WebSocket
- Server startup
serve/cmd/server/main.go - HTTP router
serve/internal/router/router.go - WebSocket handler
serve/internal/handler/ws_handler.go - Hub startup
serve/internal/handler/ws_handler.go
Realtime chat
- Hub event loop
serve/internal/logic/Hub/Hub_logic.go - Hub instance
serve/internal/logic/connection_routine/Hub_Instance.go - Connection routines
serve/internal/logic/connection_routine/enter.go - Message reader
serve/internal/logic/connection_routine/reader.go - Message writer
serve/internal/logic/connection_routine/writer.go - Client send queue
serve/internal/model/connection.go - Online user state
serve/internal/logic/Hub/Hub_logic.go
Connection data
- Connection context
serve/internal/model/connection.go - Message data
serve/internal/model/data.go
Other components
- Browser user
Connections 23
- Browser user → Vue app: uses
- Vue app → Chat room: renders
- Chat room → Online users: renders users
- Chat room → Message display: renders messages
- Chat room → HTTP router: opens WebSocket
- Server startup → HTTP router: starts server
- Server startup → Hub startup: starts Hub
- HTTP router → WebSocket handler: dispatches /ws
- WebSocket handler → Hub instance: registers connection
- WebSocket handler → Connection routines: starts routines
- Hub startup → Hub instance: runs instance
- Hub instance → Hub event loop: provides channels
- Connection routines → Message reader: reads messages
- Connection routines → Message writer: starts writer
- Message reader → Hub instance: queues events
- Message reader → Online user state: updates users
- Hub event loop → Online user state: reads user list
- Hub event loop → Client send queue: enqueues broadcasts
- Message writer → Client send queue: consumes messages
- Message writer → Browser user: writes WebSocket
- WebSocket handler → Connection context: creates context
- Connection context → Message data: holds payload
- Chat room → Message data: sends and receives JSON