feat: add writeJSON function

This commit is contained in:
2025-09-29 14:40:07 +07:00
parent dfbe2f2808
commit 9d74e72ede

View File

@@ -337,6 +337,12 @@ func (wsClient *SafeWebsocketClient) DataChannel() <-chan []byte {
return wsClient.dataChannel
}
func (wsClient *SafeWebsocketClient) WriteJSON(message any) error {
return wsClient.mu.WriteHandler(func() error {
return wsClient.conn.WriteJSON(message)
})
}
func (wsClient *SafeWebsocketClient) Close() error {
wsClient.mu.WriteHandler(func() error {
if wsClient.cancelFuncs != nil {