Compare commits

...

2 Commits

Author SHA1 Message Date
b71e8121e2 fix: fixing shut down deadlock 2025-10-16 06:47:51 +07:00
9c6db30550 feat: add data retrieval close function 2025-10-13 08:30:42 +07:00

View File

@@ -338,7 +338,7 @@ func (wsClient *SafeWebsocketClient) startPingTicker(ctx context.Context) {
for { for {
select { select {
case <-ctx.Done(): case <-ctx.Done():
log.Println("ping ticker stopped") log.Println("ping ticker canceled by context")
return return
case <-ticker.C: case <-ticker.C:
wsClient.writeChan <- Message{ wsClient.writeChan <- Message{
@@ -425,6 +425,10 @@ func (wsClient *SafeWebsocketClient) DataChannel() <-chan []byte {
return wsClient.dataChannel return wsClient.dataChannel
} }
func (wsClient *SafeWebsocketClient) CloseDataChannel() {
close(wsClient.dataChannel)
}
func (wsClient *SafeWebsocketClient) Write(data []byte) error { func (wsClient *SafeWebsocketClient) Write(data []byte) error {
wsClient.writeChan <- Message{ wsClient.writeChan <- Message{
MessageType: MessageTypeText, MessageType: MessageTypeText,
@@ -452,7 +456,7 @@ func (wsClient *SafeWebsocketClient) Close() error {
wsClient.conn.Close() wsClient.conn.Close()
} }
wsClient.isConnected = false wsClient.isConnected = false
// close(wsClient.dataChannel) close(wsClient.dataChannel)
return nil return nil
} }