Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b71e8121e2 | |||
| 9c6db30550 | |||
| bc2017e67d |
@@ -41,7 +41,7 @@ func NewHub() *Hub {
|
||||
Broadcast: make(chan []byte, 1),
|
||||
Register: make(chan *Client, 1),
|
||||
Unregister: make(chan *Client, 1),
|
||||
Clients: make(map[*Client]bool, 1),
|
||||
Clients: make(map[*Client]bool, 0),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@ func (wsClient *SafeWebsocketClient) startPingTicker(ctx context.Context) {
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
log.Println("ping ticker stopped")
|
||||
log.Println("ping ticker canceled by context")
|
||||
return
|
||||
case <-ticker.C:
|
||||
wsClient.writeChan <- Message{
|
||||
@@ -425,6 +425,10 @@ func (wsClient *SafeWebsocketClient) DataChannel() <-chan []byte {
|
||||
return wsClient.dataChannel
|
||||
}
|
||||
|
||||
func (wsClient *SafeWebsocketClient) CloseDataChannel() {
|
||||
close(wsClient.dataChannel)
|
||||
}
|
||||
|
||||
func (wsClient *SafeWebsocketClient) Write(data []byte) error {
|
||||
wsClient.writeChan <- Message{
|
||||
MessageType: MessageTypeText,
|
||||
@@ -452,7 +456,7 @@ func (wsClient *SafeWebsocketClient) Close() error {
|
||||
wsClient.conn.Close()
|
||||
}
|
||||
wsClient.isConnected = false
|
||||
// close(wsClient.dataChannel)
|
||||
close(wsClient.dataChannel)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user