Skip to content

LIOU2021/Golang-realtime-chat-rooms

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang-realtime-chat-rooms

Start the server

go run main.go

http://localhost:8080/room/1

how to use ?

  • step1 : New your hub. see .\ws\hub_list.go
var DemoHub = NewHub("demo_hub")
  • step2 : listen your hub. see .\main.go
go ws.DemoHub.Run()
  • step3 : create your ws router
router.GET("/ws/:roomId", func(c *gin.Context) {
    roomId := c.Param("roomId")
    ws.ServeWs(c.Writer, c.Request, ws.DemoHub, roomId)
})

usage example

// push message to room id 2
ws.DemoHub.PushRoom([]byte("hello word"), "2")
//push message to all connect user
ws.DemoHub.PushAll([]byte("hello every body"))

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 70.5%
  • HTML 29.5%