Add new WebSocket command
This commit is contained in:
parent
95f10be6a8
commit
65503ee846
8
ws.go
8
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue