Skip to content

Example of using gorilla websocket with gin (chat with rooms)

License

Notifications You must be signed in to change notification settings

tinkerbaj/chat-websocket-gin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chat-websocket-gin

Example of using gorilla websocket with gin (chat with rooms)

  • Clone repo
  • Enter in console "go mod tidy" to fetch all packages project need
  • Enter "go run main.go" to start server

Websocket route will be ws://localhost:8080/ws/ + any name

for example: ws://localhost:8080/ws/room1

You can use WebSocket King Client Chrome extension to test it If you use room1 id for example like ws://localhost:8080/ws/room1 you can use this JSON

{
"type": "message",
"sender": "user1",
"recipient": "user2",
"content": "How are you",
"id": "room1"
}

run 2 clients on the same URL ws://localhost:8080/ws/room1 and you can use the same JSON just important is to send on the same id in our case room1

Releases

No releases published

Packages

No packages published

Languages