public void OnSendToClient(PktBase pkt) { if (client == null) { return; } client.Response(pkt); }
private static void RegistPacketResponers <T>(Action <T> response) where T : PktBase, new() { if (AFactoryPacket.Instance.GetCaller(PktBase.GetPktDef(typeof(T))) == null) { AFactoryPacket.Instance.RegistPackets(new Caller <T>((resp, t) => { response(t); })); } }
public static void RemoteCall(PktBase pkt) { if (!bConnected) { clientComm.resultServerDisconnected(); return; } System.Threading.Tasks.Task.Run(async() => { await connection.Send(pkt); }); }
internal void SendTo(string psid, PktBase pkt) { var p = OnGetPlayerByPSID(psid); if (p == null) { return; } p.client.Response(pkt); }
internal void SendTo(string id, PktBase pkt) { var p = APlayerManager.Instance.OnGetPlayerByID(id); if (p == null) { return; } p.client.Response(pkt); }
public static void RemoteCall <T>(PktBase pkt, Action <T> response) where T : PktBase, new() { if (!bConnected) { clientComm.resultServerDisconnected(); return; } System.Threading.Tasks.Task.Run(async() => { await connection.Send(pkt); }); RegistPacketResponers <T>(response); }
public static void PushMsg(ClientConnection client, PktBase message) { ByteStream buffer = new ByteStream(1024, (byte)eMessageType.PacketID_Common); buffer.WriteInt(message.pktDef); var ms = new MemoryStream(); message.Serialize(ms); buffer.WriteByteArray(ms.ToArray()); client.SendPacket(buffer); }
public void Response(PktBase message) { ByteStream buffer = new ByteStream(1024, (byte)eMsgType); buffer.WriteInt(message.pktDef); var ms = new MemoryStream(); message.Serialize(ms); buffer.WriteByteArray(ms.ToArray()); m_client.SendPacket(buffer); }
public void RemoteCall(PktBase message) { ByteStream buffer = new ByteStream(1024, (byte)eMessageType.PacketID_Common); buffer.WriteInt(message.pktDef); var ms = new MemoryStream(); message.Serialize(ms); buffer.WriteByteArray(ms.ToArray()); m_client.SendPacket(buffer); }
internal void Broadcast(PktBase pkt) { foreach (var player in dAllPlayers) { var p = APlayerManager.Instance.OnGetPlayerByID(player.Key); if (p == null || p.client == null) { continue; } p.client.Response(pkt); } }
public override void Call(IResponer responer, byte[] bytes) { try { delCaller(responer, PktBase.Deserialize <T>(bytes)); } catch (Exception ex) { AOutput.Log("Stack trace:" + ex.StackTrace); AOutput.Log("Message:" + ex.Message); } }
public override void Call(IResponer responer, byte[] bytes) { try { delCaller(responer, PktBase.Deserialize <T>(bytes)); } catch (Exception ex) { Console.WriteLine("Stack trace:" + ex.StackTrace); Console.WriteLine("Message:" + ex.Message); } }
public static void SendToClient(string psid, PktBase pkt) { Instance.SendTo(psid, pkt); }
public void Response(PktBase message) { ServerUtils.PushMsg(Client, message); }
public async Task Send(PktBase pkt) { await Task.Run(() => { client?.RemoteCall(pkt); }); }
public static void RemoteCall <T>(PktBase pkt, Action <T> response) where T : PktBase, new() { RemoteCall(pkt); RegistPacketResponers(response); }