Exemple #1
0
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)
		}
	}
}
Exemple #2
0
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
}