feat: add writeJSON function
This commit is contained in:
@@ -337,6 +337,12 @@ func (wsClient *SafeWebsocketClient) DataChannel() <-chan []byte {
|
|||||||
return wsClient.dataChannel
|
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 {
|
func (wsClient *SafeWebsocketClient) Close() error {
|
||||||
wsClient.mu.WriteHandler(func() error {
|
wsClient.mu.WriteHandler(func() error {
|
||||||
if wsClient.cancelFuncs != nil {
|
if wsClient.cancelFuncs != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user