Exemplo n.º 1
0
func ServerRawMessage(conn *GxTcpConn, msg *GxMessage) error {
	Debug("new server message, remote: %s %s", conn.Conn.RemoteAddr().String(), msg.String())

	client := clientRouter.FindConnById(msg.GetId())
	if client == nil {
		Debug("msg cannot find target, remote: %s, msg: %s", conn.Conn.RemoteAddr().String(),
			msg.String())
		return nil
	}

	client.Send(msg)
	if msg.GetMask(MessageMaskDisconn) {
		client.Conn.Close()
	}
	return nil
}
Exemplo n.º 2
0
func (conn *GxTcpConn) SaveProcessMsg(msg *GxMessage) {
	if !conn.MessageCtrl {
		return
	}

	conn.mutex.Lock()
	defer conn.mutex.Unlock()

	//服务端发送的通知seq为0
	if msg.GetMask(MessageMaskNotify) {
		return
	}

	if conn.msg == nil {
		conn.msg = msg
	} else {
		if conn.msg.GetSeq() == msg.GetSeq() && conn.msg.GetCmd() == msg.GetCmd() {
			conn.msg = nil
		}
	}

}