コード例 #1
0
        private void Send2Client(eUnitModType type, PackBaseS2C msg)
        {
            eUnitAttrObserver oberver = this.GetObserverType(type);

            switch (oberver)
            {
            case eUnitAttrObserver.Single:
                ServerNetManager.Instance.SendProxy(msg.client_uid, msg, false);
                break;

            case eUnitAttrObserver.BoardcaseScreen:
            {
                ServerNetManager.Instance.SendProxy(msg.client_uid, msg, false);
                //转发其他同屏玩家
                List <long> list_unit = AOIManager.Instance.GetScreenUnit(m_owner_unit.obj_idx);
                if (list_unit != null && list_unit.Count > 0)
                {
                    foreach (var idx in list_unit)
                    {
                        Player player = UnitManager.Instance.GetUnitByIdx(idx) as Player;
                        if (player == null)
                        {
                            continue;
                        }
                        ServerNetManager.Instance.SendProxy(player.client_uid, msg, false);
                    }
                }
            }
            break;

            case eUnitAttrObserver.Boardcase:
                ServerNetManager.Instance.SendProxy(msg.client_uid, msg, true);
                break;
            }
        }
コード例 #2
0
 public void Set(ClientUID client_uid, PackBaseS2C packet)
 {
     if (!is_broadcast && (client_uid.srv_uid == 0 || client_uid.conn_idx == 0))
     {
         Console.WriteLine("未设置转发目标服务器数据");
     }
     packet.client_uid = client_uid;
     packet.Write(data);
 }
コード例 #3
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);//回收消息本身
 }
コード例 #4
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);
        }
コード例 #5
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);
        }