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); } }
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); } }
public static void SetStatus(Config.GameServer config, ServerStatus status) { if (status == null) { m_Status.Remove(config); } else { m_Status[config] = status; } }
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); } }
public static ServerStatus GetStatus(Config.GameServer config) { return(m_Status == null ? null : (ServerStatus)m_Status[config]); }
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); } }