/* sendPublicationWithTimeout */ func (self *Hub) sendPublicationWithTimeout(conn interfaces.Connection, i interface{}, timeout time.Duration) error { select { case conn.SendChannel() <- i: return nil case <-time.After(timeout): return errors.New("Send to connection timeout") } }
/* removeConnection does the house keeping for removing a connection to the hub */ func (self *Hub) removeConnection(conn interfaces.Connection) error { b, err := self.isRegisteredConnection(conn) if err != nil { return errors.New("cannot remove connection: " + err.Error()) } if !b { return errors.New("connection is not registered") } conn.SetHub(nil) self.removeConnectionSubscriptions(conn) delete(self.connections, conn) sendChan := conn.SendChannel() close(sendChan) return nil }