Beispiel #1
0
Datei: ws.go Projekt: tiffon/nvlv
func sendOnWS(c *clientBody, ws *websocket.Conn, key string, data interface{}, keyValPairs ...interface{}) {

	xtraKeys, err := cmn.AppendKVPs(c.Data, keyValPairs)
	if err != nil {
		log.Println("Error appending extra key and values in send Err: ", err)
	}
	c.Data[key] = data
	websocket.JSON.Send(ws, c)

	delete(c.Data, key)
	if xtraKeys != nil {
		for _, key := range xtraKeys {
			delete(c.Data, key)
		}
	}
}
Beispiel #2
0
Datei: ws.go Projekt: tiffon/nvlv
func (c *clientBody) send(ws *websocket.Conn, keyvals ...interface{}) error {

	keys, err := cmn.AppendKVPs(c.Data, keyvals)
	if err != nil {
		log.Println("Error appending extra key and values in send Err: ", err)
		return err
	}
	websocket.JSON.Send(ws, c)

	if keys != nil {
		for _, key := range keys {
			delete(c.Data, key)
		}
	}
	return nil
}