feat: add data retrieval close function

This commit is contained in:
2025-10-13 08:30:42 +07:00
parent bc2017e67d
commit 9c6db30550

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,