From add4e7364686077dac987ea06756366e43d259f2 Mon Sep 17 00:00:00 2001 From: Hendrik Steidl <837420+hsteidl@users.noreply.github.com> Date: Tue, 5 Mar 2024 12:36:55 +0100 Subject: [PATCH] refactor(*): fix merge problems --- ocpp1.6/types/types.go | 3 ++- ocppj/server.go | 2 +- ws/websocket.go | 5 ++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ocpp1.6/types/types.go b/ocpp1.6/types/types.go index 9ff86654..a2539c45 100644 --- a/ocpp1.6/types/types.go +++ b/ocpp1.6/types/types.go @@ -2,8 +2,9 @@ package types import ( - "github.com/lorenzodonini/ocpp-go/ocppj" "gopkg.in/go-playground/validator.v9" + + "github.com/lorenzodonini/ocpp-go/ocppj" ) const ( diff --git a/ocppj/server.go b/ocppj/server.go index ac2d3489..7d651329 100644 --- a/ocppj/server.go +++ b/ocppj/server.go @@ -244,7 +244,7 @@ func (s *Server) ocppMessageHandler(wsChannel ws.Channel, data []byte) error { log.Error(err) return err } - log.Debugf("received JSON message from %s: %s", wsChannel.ID(), string(data)) + // Get pending requests for client pending := s.RequestState.GetClientState(wsChannel.ID()) message, err := s.ParseMessage(parsedJson, pending) diff --git a/ws/websocket.go b/ws/websocket.go index ab2d37a8..4b1817e5 100644 --- a/ws/websocket.go +++ b/ws/websocket.go @@ -19,6 +19,7 @@ import ( "github.com/gorilla/mux" "github.com/gorilla/websocket" + "github.com/lorenzodonini/ocpp-go/logging" ) @@ -1015,9 +1016,7 @@ func (client *Client) IsConnected() bool { } func (client *Client) Write(data []byte) error { - client.mutex.Lock() - defer client.mutex.Unlock() - if !client.connected { + if !client.IsConnected() { return fmt.Errorf("client is currently not connected, cannot send data") } log.Debugf("queuing data for server")