コード例 #1
0
ファイル: GameClient.cs プロジェクト: geo-vi/NettyBaseTD
        public void Send(byte[] bytes)
        {
            try
            {
                var gameSession = World.StorageManager.GetGameSession(UserId);
                if (gameSession != null)
                {
                    if (gameSession.InProcessOfReconection || gameSession.InProcessOfDisconnection)
                    {
                        return;
                    }
                    if (gameSession.Player.Controller != null)
                    {
                        gameSession.LastActiveTime = DateTime.Now;
                    }

                    XSocket.Write(bytes);
                    //Console.WriteLine(Out.GetCaller() + $" ({DateTime.Now})");
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("->" + Out.GetCaller());
                //new ExceptionLog("socket", "Unable to send packet / Connected?", e);
            }
        }
コード例 #2
0
        private void XSocketOnOnReceive(object sender, EventArgs eventArgs)
        {
            var packet = ((StringArgs)eventArgs).Packet;

            const string policyPacket = "<?xml version=\"1.0\"?>\r\n" +
                                        "<!DOCTYPE cross-domain-policy SYSTEM \"/xml/dtds/cross-domain-policy.dtd\">\r\n" +
                                        "<cross-domain-policy>\r\n" +
                                        "<allow-access-from domain=\"*\" to-ports=\"*\" />\r\n" +
                                        "</cross-domain-policy>";

            if (packet.StartsWith("<policy-file-request/>"))
            {
                XSocket.Write(policyPacket);
            }
            else
            {
                Console.WriteLine("Errorino with policy request: {0}", packet);
            }
        }