예제 #1
0
        public static void PlayServer(NetState state, PacketReader pvSrc)
        {
            int index = pvSrc.ReadInt16();

            ServerInfo[] info = state.ServerInfo;
            IAccount     a    = state.Account;

            if (info == null || a == null || index < 0 || index >= info.Length)
            {
                state.Dispose();
            }
            else
            {
                ServerInfo si = info[index];

                PlayServerAck.m_AuthID = GenerateAuthID();

                /* send AuthID to game server? */
                Config.GameServer config = Core.Config.GameServers[si.Name];
                if (config != null && config.SendAuthID)
                {
                    NetState ns2 = NetState.GameServerClient(config);
                    if (ns2 != null)
                    {
                        ns2.Send(new AddAuthID(PlayServerAck.m_AuthID, state.Account.ToString()));
                    }
                }

                state.SentFirstPacket = false;
                state.Send(new PlayServerAck(si));

                log.InfoFormat("Client {0} playing server '{1}'",
                               state, si.Name);
            }
        }
예제 #2
0
        public static NetState GameServerClient(Config.GameServer config)
        {
            if (config == null)
            {
                return(null);
            }

            String   address = config.Address.ToString();
            NetState ns      = (NetState)m_GameServers[address];

            if (ns != null)
            {
                return(ns);
            }

            try {
                ns = new NetState(config.Address, Core.MessagePump);
                ns.Start();
                ns.Send(new SendSeed());
                m_GameServers[address] = ns;
                return(ns);
            } catch (Exception e) {
                log.Error(String.Format("Exception while trying to connect to game server {0} ({1}): {2}",
                                        config.Name, address),
                          e);
                return(null);
            }
        }
예제 #3
0
 public static void SetStatus(Config.GameServer config, ServerStatus status)
 {
     if (status == null)
     {
         m_Status.Remove(config);
     }
     else
     {
         m_Status[config] = status;
     }
 }
예제 #4
0
        public ServerQuery(Config.GameServer config)
        {
            m_Config = config;

            try {
                m_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                /* connect socket */
                m_Callback = new AsyncCallback(OnConnect);
                m_Socket.BeginConnect(m_Config.Address, m_Callback, null);
            } catch (Exception ex) {
                log.Error(ex);
            }
        }
예제 #5
0
 public static ServerStatus GetStatus(Config.GameServer config)
 {
     return(m_Status == null
                         ? null
                         : (ServerStatus)m_Status[config]);
 }
예제 #6
0
        public ServerQuery(Config.GameServer config)
        {
            m_Config = config;

            try {
                m_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                /* connect socket */
                m_Callback = new AsyncCallback(OnConnect);
                m_Socket.BeginConnect(m_Config.Address, m_Callback, null);
            } catch (Exception ex) {
                log.Error(ex);
            }
        }