MCPcopy Create free account
hub / github.com/ebosas/microservices / handleWriteWebsocket

Function handleWriteWebsocket

cmd/server/server.go:153–163  ·  view source on GitHub ↗

handleWriteWebsocket writes a Rabbit message to Websocket. A Rabbit consumer only passes a message. So, a Websocket connection is additionally passed using a closure.

(ws *websocket.Conn)

Source from the content-addressed store, hash-verified

151// A Rabbit consumer only passes a message. So, a Websocket connection is
152// additionally passed using a closure.
153func handleWriteWebsocket(ws *websocket.Conn) func(d amqp.Delivery) error {
154 return func(d amqp.Delivery) error {
155 ws.SetWriteDeadline(time.Now().Add(10 * time.Second))
156 // TODO: check msg
157 err := ws.WriteMessage(websocket.TextMessage, []byte(d.Body))
158 if err != nil {
159 return fmt.Errorf("write websocket: %v", err)
160 }
161 return nil
162 }
163}
164
165// handlePublishRabbit publishes a Websocket message to a Rabbit
166// exchange with the the back-end and database routing keys.

Callers 1

handleWebsocketFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected