Example #1
0
        public InboundConnection(Socket s, ServerBase server, bool isBlocking)
            : base(isBlocking)
        {
            MyServer = server;
            NUM_CONNECTIONS_IN_MEMORY++;
            try
            {
                MyTCPSocket = s;
                MyTCPSocket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, DisableTCPDelay);

                m_TimeoutTimer = new Timer();

                int timeout = ConfigHelper.GetIntConfig("PlayerConnectionTimeout");
                if (timeout < 1)
                {
                    timeout = 10;
                }

                m_TimeoutTimer.Interval = timeout * 1000;
                m_TimeoutTimer.Elapsed += new ElapsedEventHandler(TimeoutTimer_Elapsed);
                m_TimeoutTimer.Start();

                ServerUser = new Shared.ServerUser();
                ServerUser.MyConnection = this;

                // Track the network socket associated with this connection object.
                string msg = "";
                if (!ConnectionManager.TrackUserSocket(this, ref msg))
                {
                    KillConnection(msg);
                    return;
                }

                if (!Transit.ListenForDataOnSocket())
                {
                    KillConnection("Remote end closed socket.");
                    return;
                }

                Log1.Logger("Server").Info("Now have [" + ConnectionManager.ConnectionCount.ToString() + " connections] attached.");
            }
            catch (Exception e)
            {
                KillConnection("Error instantiating Inbound connection object " + GetType().ToString() + " : " + e.Message);
                Log1.Logger("Server.Network").Error("Error instantiating Inbound connection object " + GetType().ToString() + " : " + e.Message, e);
                return;
            }
            SendRijndaelExchangeRequest();
        }
Example #2
0
        private void OnCharacterDetailRequest(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus.Inbound.Client").Debug("Character detail request from " + ServerUser.AccountName + ".");

            PacketGenericMessage msg = r as PacketGenericMessage;
            int id = msg.Parms.GetIntProperty(2).GetValueOrDefault(-1);
            WispCharacterDetail ci = new WispCharacterDetail(id);
            string rmsg            = "";

            ServerUser su = new Shared.ServerUser();

            su.ID = Guid.Empty;
            ServerCharacterInfo sci = null;

            if (MyServer.RequireAuthentication)
            {
                sci = CharacterUtil.Instance.LoadCharacter(su, id, ref rmsg);
            }

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.ReplyMessage = rmsg;

            if (sci == null)
            {
                r.ReplyPacket.ReplyCode    = ReplyType.Failure;
                r.ReplyPacket.ReplyMessage = "Character not found. " + rmsg;
            }
            else
            {
                ci.CharacterName = sci.CharacterInfo.CharacterName;
                ci.ID            = sci.ID;
                ci.LastLogin     = sci.LastLogin;
                ci.Properties    = sci.Properties;
                ci.Stats         = sci.Stats;

                r.ReplyPacket.Parms.SetProperty(2, ci as ISerializableWispObject);
            }

            r.ReplyPacket.Parms.SetProperty(1, MyServer.ServerUserID);
        }
        private void OnCharacterDetailRequest(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus.Inbound.Client").Debug("Character detail request from " + ServerUser.AccountName + ".");

            PacketGenericMessage msg = r as PacketGenericMessage;
            int id = msg.Parms.GetIntProperty(2).GetValueOrDefault(-1);
            WispCharacterDetail ci = new WispCharacterDetail(id);
            string rmsg = "";

            ServerUser su = new Shared.ServerUser();
            su.ID = Guid.Empty;
            ServerCharacterInfo sci = null;
            if (MyServer.RequireAuthentication)
            {
                sci = CharacterUtil.Instance.LoadCharacter(su, id, ref rmsg);
            }

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.ReplyMessage = rmsg;

            if (sci == null)
            {
                r.ReplyPacket.ReplyCode = ReplyType.Failure;
                r.ReplyPacket.ReplyMessage = "Character not found. " + rmsg;
            }
            else
            {
                ci.CharacterName = sci.CharacterInfo.CharacterName;
                ci.ID = sci.ID;
                ci.LastLogin = sci.LastLogin;
                ci.Properties = sci.Properties;
                ci.Stats = sci.Stats;

                r.ReplyPacket.Parms.SetProperty(2, ci as ISerializableWispObject);
            }

            r.ReplyPacket.Parms.SetProperty(1, MyServer.ServerUserID);
        }