From 63d8f72ea7bb83443c8e3a9785f8901acfd4f6f1 Mon Sep 17 00:00:00 2001 From: jano3 <jano@bob.co.za> Date: Fri, 2 Aug 2024 14:19:22 +0200 Subject: [PATCH] Update functions to post to websocket connection IDs --- websocket_utils/websocket_utils.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/websocket_utils/websocket_utils.go b/websocket_utils/websocket_utils.go index dc27a36..7c508a7 100644 --- a/websocket_utils/websocket_utils.go +++ b/websocket_utils/websocket_utils.go @@ -59,16 +59,22 @@ func NewClient(req *events.APIGatewayWebsocketProxyRequest, config aws.Config) * } } -func (s APIGateWayClientWithHelpers) PostToConnectionIDs(data []byte, connectionIDs []string) error { +func (s APIGateWayClientWithHelpers) PostToConnectionID(data []byte, connectionID string) error { + _, err := s.APIGatewayClient.PostToConnection(context.TODO(), &apigatewaymanagementapi.PostToConnectionInput{ + ConnectionId: &connectionID, + Data: data, + }) + return err +} + +func (s APIGateWayClientWithHelpers) PostToConnectionIDs(data []byte, connectionIDs []string) { for _, connectionID := range connectionIDs { _, err := s.APIGatewayClient.PostToConnection(context.TODO(), &apigatewaymanagementapi.PostToConnectionInput{ ConnectionId: &connectionID, Data: data, }) if err != nil { - return err + logs.Info("failed to send data to connection ID: %s", connectionID) } } - - return nil } -- GitLab