Esempio n. 1
0
        public void Run(uint[] players, IPaylodable paylodable)
        {
            var sender = world.GetBehavior <UdpSender>();

            foreach (var item in players)
            {
                sender.Send(item, paylodable);
            }
        }
Esempio n. 2
0
        public void Send(string nName, IPaylodable paylodable)
        {
            var  con = world.Globel.GetComponent <ConnectorsComponent>();
            uint id;

            if (con.connectionNames.TryGetValue(nName, out id))
            {
                Send(id, paylodable);
            }
        }
Esempio n. 3
0
        public override void Deal(uint client, IPaylodable paylodable)
        {
            T m = (T)paylodable;

            if (m == null)
            {
                throw new Exception("消息类型转换错误");
            }
            Handle(client, m);
        }
Esempio n. 4
0
        public void Send(uint client, IPaylodable paylodable)
        {
            var end = world.GetComponent <EndPointComponent>(client);

            if (end == null)
            {
                return;
            }
            uint pid  = world.Globel.GetComponent <PIDComponent>().Pid;
            var  Sock = world.Globel.GetComponent <SocketComponent>();

            byte[] data = pid.ToBytes().Add(ConDefine.msg).Add(paylodable.Type.ToBytes()).Add(paylodable.ToBytes());
            Sock.socket.SendTo(data, end.remote);
            unSafeByteHelper.Return(data);
        }
Esempio n. 5
0
 public override Task Run(UdpResult result, ConnectorsComponent connectors, UdpSender sender)
 {
     return(Task.Factory.StartNew(() =>
     {
         uint eid;
         if (connectors.dictionary.TryGetValue(result.endPoint, out eid))
         {
             ushort func = result.stream.GetUShort();
             IPaylodable paylodable = MsgMaper.Get(func);
             if (paylodable == null)
             {
                 return;
             }
             paylodable.GetFrom(result.stream);
             APDealer dealer = world.GetBehavior <APDealer>(MsgMaper.Get(paylodable.GetType().Name));
             dealer?.Deal(eid, paylodable);
             ByteStream.Return(result.stream as ByteStream);
         }
     }));
 }
Esempio n. 6
0
 public abstract void Deal(uint cient, IPaylodable paylodable);