From 65503ee8467b04a7c9012b6f2474def3d4dc1b2f Mon Sep 17 00:00:00 2001 From: Ivan Danyliuk Date: Fri, 24 Aug 2018 23:11:48 +0300 Subject: [PATCH] Add new WebSocket command --- ws.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ws.go b/ws.go index 3f10c5f..85b56e7 100644 --- a/ws.go +++ b/ws.go @@ -31,8 +31,7 @@ func NewWSServer(layout *layout.Layout) *WSServer { } type WSResponse struct { - Type MsgType `json:"type"` - //Positions []*position `json:"positions,omitempty"` + Type MsgType `json:"type"` Positions map[string]*layout.Object `json:"positions,omitempty"` Graph json.RawMessage `json:"graph,omitempty"` Propagation *PropagationLog `json:"propagation,omitempty"` @@ -54,7 +53,8 @@ const ( // WebSocket commands const ( - CmdInit WSCommand = "init" + CmdInit WSCommand = "init" + CmdSendMessage WSCommand = "send_message" ) func (ws *WSServer) Handle(w http.ResponseWriter, r *http.Request) { @@ -91,6 +91,8 @@ func (ws *WSServer) processRequest(c *websocket.Conn, mtype int, data []byte) { ws.updatePositions() ws.sendPositions(c) ws.sendPropagationData(c) + case CmdSendMessage: + ws.sendPropagationData(c) } }