public void Run(uint[] players, IPaylodable paylodable) { var sender = world.GetBehavior <UdpSender>(); foreach (var item in players) { sender.Send(item, paylodable); } }
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); } }
public override void Deal(uint client, IPaylodable paylodable) { T m = (T)paylodable; if (m == null) { throw new Exception("消息类型转换错误"); } Handle(client, m); }
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); }
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); } })); }
public abstract void Deal(uint cient, IPaylodable paylodable);