public void OnSendToClient(PktBase pkt)
 {
     if (client == null)
     {
         return;
     }
     client.Response(pkt);
 }
Beispiel #2
0
 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); }));
     }
 }
Beispiel #3
0
 public static void RemoteCall(PktBase pkt)
 {
     if (!bConnected)
     {
         clientComm.resultServerDisconnected();
         return;
     }
     System.Threading.Tasks.Task.Run(async() => { await connection.Send(pkt); });
 }
Beispiel #4
0
    internal void SendTo(string psid, PktBase pkt)
    {
        var p = OnGetPlayerByPSID(psid);

        if (p == null)
        {
            return;
        }
        p.client.Response(pkt);
    }
Beispiel #5
0
    internal void SendTo(string id, PktBase pkt)
    {
        var p = APlayerManager.Instance.OnGetPlayerByID(id);

        if (p == null)
        {
            return;
        }
        p.client.Response(pkt);
    }
Beispiel #6
0
 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);
        }
Beispiel #10
0
 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);
     }
 }
Beispiel #11
0
 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);
     }
 }
Beispiel #12
0
 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);
     }
 }
Beispiel #13
0
 public static void SendToClient(string psid, PktBase pkt)
 {
     Instance.SendTo(psid, pkt);
 }
Beispiel #14
0
 public void Response(PktBase message)
 {
     ServerUtils.PushMsg(Client, message);
 }
 public async Task Send(PktBase pkt)
 {
     await Task.Run(() => { client?.RemoteCall(pkt); });
 }
Beispiel #16
0
 public static void RemoteCall <T>(PktBase pkt, Action <T> response)
     where T : PktBase, new()
 {
     RemoteCall(pkt);
     RegistPacketResponers(response);
 }