chore: cleaning unused mutex

This commit is contained in:
2025-09-26 09:16:35 +07:00
parent 4111dd0f25
commit f32d97eac4
5 changed files with 8 additions and 41 deletions

View File

@@ -8,6 +8,7 @@ import (
"strings"
"time"
custom_rwmutex "git.neurocipta.com/rogerferdinan/custom-rwmutex"
"git.neurocipta.com/rogerferdinan/safe-web-socket/internal"
"github.com/gorilla/websocket"
)
@@ -74,7 +75,7 @@ func (b *SafeWebsocketClientBuilder) Build() (*SafeWebsocketClient, error) {
ctx: ctx,
cancel: cancel,
dataChannel: make(chan []byte, 1),
mu: internal.NewCustomRwMutex(),
mu: custom_rwmutex.NewCustomRwMutex(),
reconnectCh: make(chan struct{}, 1),
isConnected: false,
}
@@ -94,7 +95,7 @@ type SafeWebsocketClient struct {
path *string
rawQuery *string
dataChannel chan []byte
mu *internal.CustomRwMutex
mu *custom_rwmutex.CustomRwMutex
conn *websocket.Conn
ctx context.Context
cancel context.CancelFunc
@@ -181,7 +182,7 @@ func (wsClient *SafeWebsocketClient) startReceiveHandler() {
log.Println("Reconnect handler stopped")
return
default:
if err := wsClient.mu.WriteHandler(func() error {
if err := wsClient.mu.ReadHandler(func() error {
conn := wsClient.conn
if conn == nil {