Feat v0.5.0 realtime dialog (#30)
All checks were successful
All checks were successful
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #30.
This commit is contained in:
@@ -316,6 +316,26 @@ func (c *Conn) readPump() {
|
||||
continue
|
||||
}
|
||||
|
||||
// v0.5.0: Room management — intercept before bus publish (like ping)
|
||||
if event.Label == "room.subscribe" {
|
||||
var req struct {
|
||||
Room string `json:"room"`
|
||||
}
|
||||
if json.Unmarshal(event.Payload, &req) == nil && req.Room != "" && len(c.rooms) < 100 {
|
||||
c.JoinRoom(req.Room)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if event.Label == "room.unsubscribe" {
|
||||
var req struct {
|
||||
Room string `json:"room"`
|
||||
}
|
||||
if json.Unmarshal(event.Payload, &req) == nil && req.Room != "" {
|
||||
c.LeaveRoom(req.Room)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// Validate: only accept events allowed from clients
|
||||
if !ShouldAcceptFromClient(event.Label) {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user