1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-15 07:55:57 +00:00

sync with master fixes and add more details in the HISTORY.md for the upcoming release

Former-commit-id: 13d5f3bd0dd844dbe2f709cfe8423a7417542744
This commit is contained in:
Gerasimos (Makis) Maropoulos
2018-10-17 07:13:34 +03:00
parent e3876d793c
commit df85be52a4
2 changed files with 90 additions and 6 deletions

View File

@@ -52,9 +52,9 @@ type (
func New(cfg Config) *Server {
cfg = cfg.Validate()
return &Server{
config: cfg,
connections: sync.Map{}, // ready-to-use, this is not necessary.
rooms: make(map[string][]string),
config: cfg,
connections: sync.Map{}, // ready-to-use, this is not necessary.
rooms: make(map[string][]string),
onConnectionListeners: make([]ConnectionFunc, 0),
upgrader: websocket.Upgrader{
HandshakeTimeout: cfg.HandshakeTimeout,
@@ -352,9 +352,12 @@ func (s *Server) GetConnectionsByRoom(roomName string) []Connection {
// let's keep it unexported for the best.
func (s *Server) emitMessage(from, to string, data []byte) {
if to != All && to != Broadcast {
if s.rooms[to] != nil {
s.mu.RLock()
room := s.rooms[to]
s.mu.RUnlock()
if room != nil {
// it suppose to send the message to a specific room/or a user inside its own room
for _, connectionIDInsideRoom := range s.rooms[to] {
for _, connectionIDInsideRoom := range room {
if c, ok := s.getConnection(connectionIDInsideRoom); ok {
c.writeDefault(data) //send the message to the client(s)
} else {