Ejemplo n.º 1
0
/*
websocket接收发送消息
*/
func doWebSocket(w http.ResponseWriter, r *http.Request, conn *websocket.Conn) {
	for {
		var inputData []byte
		msgType, inputData, err := conn.ReadMessage()
		if err != nil {
			logger.Println(tag_customRoute, err)
			return
		}
		logger.Println(tag_customRoute, "receive data:"+string(inputData))
		err = conn.WriteMessage(msgType, inputData)
		if err != nil {
			logger.Println(tag_customRoute, err)
			return
		}
	}
}