Exemplo n.º 1
0
        private void HandleReqProxyMsgToClient(PacketBase packet)
        {
            ProxyS2CMsg proxy_msg = packet as ProxyS2CMsg;

            //转发的消息id
            ushort header = proxy_msg.data.ReadUShort();

            //由于ws2c和ss2c有部分消息共用(如ws上的聊天用到了ss2c的聊天),这里屏蔽id检测
            //if (header < ProtocolID.MSG_BASE_SS2C || header >= ProtocolID.MSG_BASE_SS2C + ProtocolID.MSG_APPLAYER_PER_INTERVAL)
            //{
            //    Log.Debug("收到错误的消息ID:" + header);
            //    return;
            //}
            //读clientuid
            proxy_msg.data.Peek(ref tmp_client_uid_by, tmp_client_uid_by.Length);
            tmp_client_uid.Read(tmp_client_uid_by);
            if (proxy_msg.is_broadcast)
            {
                ClientSessionManager.Instance.BroadcastProxy(header, proxy_msg.data, eSessionStatus.IN_GAMING);
            }
            else
            {
                ForClientNetManager.Instance.SendProxy(tmp_client_uid.conn_idx, header, proxy_msg.data);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 广播消息:通过gate转发给client
 /// </summary>
 public void BroadcastProxyMsg(PackBaseS2C packet)
 {
     foreach (var obj in m_app_servers)
     {
         if (obj.Value.srv_info.srv_type == eServerType.GATE)
         {
             ProxyS2CMsg msg = PacketPools.Get((ushort)ss2gs.msg.PROXY_SS_MSG) as ProxyS2CMsg;
             msg.is_broadcast = true;
             msg.Set(packet.client_uid, packet);
             obj.Value.Send(msg);
         }
     }
     PacketPools.Recover(packet);//回收消息本身
 }
Exemplo n.º 3
0
        /// <summary>
        /// 通过gate转发给client
        /// </summary>
        public int SendProxy(ClientUID client_uid, PackBaseS2C packet, bool is_broadcast = false)
        {
            int         size = 0;
            ConnAppProc app_server;

            if (m_srv_servers.TryGetValue(client_uid.srv_uid, out app_server))
            {
                ProxyS2CMsg msg = PacketPools.Get((ushort)ss2gs.msg.PROXY_SS_MSG) as ProxyS2CMsg;
                msg.is_broadcast = is_broadcast;
                msg.Set(client_uid, packet);
                size = Send(app_server.conn_idx, msg);
            }
            PacketPools.Recover(packet);//回收消息本身
            return(size);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 发给客户端
        /// </summary>
        public int SendProxy(ClientUID client_uid, PackBaseS2C packet)
        {
            int         size = 0;
            ConnAppProc app_server;

            if (m_srv_servers.TryGetValue(client_uid.srv_uid, out app_server))
            {
                ProxyS2CMsg msg = PacketPools.Get((ushort)ws2gs.msg.PROXY_WS_MSG) as ProxyS2CMsg;
                msg.Set(client_uid, packet);
                size = Send(app_server.conn_idx, msg);
            }
            else
            {
                Log.Debug("未找到服务器id:" + client_uid.srv_uid);
            }

            PacketPools.Recover(packet);//回收消息本身
            return(size);
        }