olahol/melody

Tutorial for implementing rooms

Closed this issue · 1 comments

Hello!

I understand why you prefer to keep melody as much simple as possible. However, I'm not really sure what is the recommended way to implement rooms. May I ask for the example or short tutorial?

I would like to see that broadcasting happens for the related room's clients only, without the need to filter all existing server clients.

My first thought was to call m := melody.New() multiple times, for every room, but this is confusing me:

r.GET("/ws", func(c *gin.Context) {
	m.HandleRequest(c.Writer, c.Request)
})

... handler is created only once.

Could you please show how would you implement rooms? Performance among one room's users broadcasting is most important.