static void Main(string[] args) { m_Listener = new Listener(); m_Listener.Initialize(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1800)); PacketHandlers.Register(0x00, false, 0, new OnPacketReceive(Handlers.ReceivedUnEncryptedPacket)); PacketHandlers.Register(0x01, true, 0, new OnPacketReceive(Handlers.ReceivedEncryptedPacket)); }
/// <summary> /// Initializes a client that listens for data. /// </summary> /// <param name="ClientSocket">The client's socket.</param> /// <param name="Server">The Listener instance calling this constructor.</param> /// <param name="ReceivePulse">Should this client receive a pulse at a regular interval?</param> public NetworkClient(Socket ClientSocket, Listener Server) { m_Sock = ClientSocket; m_Listener = Server; m_RecvBuf = new byte[11024]; m_Sock.BeginReceive(m_RecvBuf, 0, m_RecvBuf.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), m_Sock); }
public Form1() { InitializeComponent(); /** * BOOTSTRAP - THIS IS WHERE THE SERVER STARTS UP * STEPS: * > Start logging system * > Load configuration * > Connect to the database and test the connection * > Register packet handlers * > Start the login server service */ Logger.Initialize("log.txt"); Logger.InfoEnabled = true; Logger.DebugEnabled = true; Logger.WarnEnabled = true; GonzoNet.Logger.OnMessageLogged += new MessageLoggedDelegate(Logger_OnMessageLogged); var dbConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["MAIN_DB"]; DataAccess.ConnectionString = dbConnectionString.ConnectionString; /** TODO: Test the database **/ using (var db = DataAccess.Get()) { var testAccount = db.Accounts.GetByUsername("root"); if(testAccount == null){ db.Accounts.Create(new Account { AccountName = "root", Password = "******"/*Account.GetPasswordHash("password", "username")*/ }); } } PacketHandlers.Register(0x00, false, 0, new OnPacketReceive(LoginPacketHandlers.HandleLoginRequest)); PacketHandlers.Register(0x05, true, 0, new OnPacketReceive(LoginPacketHandlers.HandleCharacterInfoRequest)); PacketHandlers.Register(0x06, true, 0, new OnPacketReceive(LoginPacketHandlers.HandleCityInfoRequest)); PacketHandlers.Register(0x07, true, 0, new OnPacketReceive(LoginPacketHandlers.HandleCharacterCreate)); var Listener = new Listener(); Listener.Initialize(Settings.BINDING); NetworkFacade.ClientListener = Listener; NetworkFacade.CServerListener = new CityServerListener(); NetworkFacade.CServerListener.Initialize(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 2108)); //64 is 100 in decimal. PacketHandlers.Register(0x64, false, 0, new OnPacketReceive(CityServerPacketHandlers.HandleCityServerLogin)); PacketHandlers.Register(0x65, false, 0, new OnPacketReceive(CityServerPacketHandlers.HandleKeyFetch)); PacketHandlers.Register(0x66, false, 3, new OnPacketReceive(CityServerPacketHandlers.HandlePulse)); //NetworkFacade.CServerListener.Initialize(2348); }
public VMServerDriver(int port) { listener = new Listener(EncryptionMode.NoEncryption); listener.Initialize(new IPEndPoint(IPAddress.Any, port)); listener.OnConnected += SendLotState; listener.OnDisconnected += LotDC; ClientsToDC = new HashSet<NetworkClient>(); ClientsToSync = new HashSet<NetworkClient>(); History = new List<VMNetTick>(); QueuedCmds = new List<VMNetCommand>(); TickBuffer = new List<VMNetTick>(); UIDs = new Dictionary<NetworkClient, uint>(); }
public Form1() { InitializeComponent(); bool FoundConfig = ConfigurationManager.LoadCityConfig(); Logger.Initialize("Log.txt"); Logger.WarnEnabled = true; Logger.DebugEnabled = true; GonzoNet.Logger.OnMessageLogged += new GonzoNet.MessageLoggedDelegate(Logger_OnMessageLogged); CityDataModel.Logger.OnMessageLogged += new CityDataModel.MessageLoggedDelegate(Logger_OnMessageLogged); ProtocolAbstractionLibraryD.Logger.OnMessageLogged += new ProtocolAbstractionLibraryD.MessageLoggedDelegate(Logger_OnMessageLogged); if (!FoundConfig) { Logger.LogWarning("Couldn't find a ServerConfig.ini file!"); //TODO: This doesn't work... Application.Exit(); } //This has to happen for the static constructor to be called... NetworkFacade m_NetworkFacade = new NetworkFacade(); var dbConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["MAIN_DB"]; DataAccess.ConnectionString = dbConnectionString.ConnectionString; m_Listener = new Listener(); //m_Listener.OnReceiveEvent += new OnReceiveDelegate(m_Listener_OnReceiveEvent); m_LoginClient = new NetworkClient("127.0.0.1", 2108); m_LoginClient.OnNetworkError += new NetworkErrorDelegate(m_LoginClient_OnNetworkError); m_LoginClient.OnConnected += new OnConnectedDelegate(m_LoginClient_OnConnected); m_LoginClient.Connect(null); //Send a pulse to the LoginServer every second. m_PulseTimer = new System.Timers.Timer(1000); m_PulseTimer.AutoReset = true; m_PulseTimer.Elapsed += new ElapsedEventHandler(m_PulseTimer_Elapsed); m_PulseTimer.Start(); m_Listener.Initialize(Settings.BINDING); }
public VMServerDriver(int port, VMServerClosedHandler onShutdown) { listener = new Listener(EncryptionMode.NoEncryption); listener.Initialize(new IPEndPoint(IPAddress.Any, port)); listener.OnConnected += SendLotState; listener.OnDisconnected += LotDC; GlobalLink = new VMTSOGlobalLinkStub(); //final server will use DB hooked class ClientsToDC = new HashSet<NetworkClient>(); ClientsToSync = new HashSet<NetworkClient>(); QueuedCmds = new List<VMNetCommand>(); TickBuffer = new List<VMNetTick>(); ClientToUID = new Dictionary<NetworkClient, uint>(); UIDtoClient = new Dictionary<uint, NetworkClient>(); if (onShutdown != null) OnShutdown += onShutdown; SandboxBans = new BanList(); }
public Form1() { InitializeComponent(); bool FoundConfig = ConfigurationManager.LoadCityConfig(); Logger.Initialize("Log.txt"); Logger.WarnEnabled = true; Logger.DebugEnabled = true; GonzoNet.Logger.OnMessageLogged += new MessageLoggedDelegate(Logger_OnMessageLogged); if (!FoundConfig) { Logger.LogWarning("Couldn't find a ServerConfig.ini file!"); //TODO: This doesn't work... Application.Exit(); } //This has to happen for the static constructor to be called... NetworkFacade m_NetworkFacade = new NetworkFacade(); var dbConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["MAIN_DB"]; DataAccess.ConnectionString = dbConnectionString.ConnectionString; /** TODO: Test the database **/ using (var db = DataAccess.Get()) { var testAccount = db.Accounts.GetByUsername("root"); if (testAccount == null) { db.Accounts.Create(new Account { AccountName = "root", Password = "******" }); } } m_Listener = new Listener(); //m_Listener.OnReceiveEvent += new OnReceiveDelegate(m_Listener_OnReceiveEvent); m_LoginClient = new NetworkClient("127.0.0.1", 2108); m_LoginClient.OnNetworkError += new NetworkErrorDelegate(m_LoginClient_OnNetworkError); m_LoginClient.OnConnected += new OnConnectedDelegate(m_LoginClient_OnConnected); m_LoginClient.Connect(null); //Send a pulse to the LoginServer every second. m_PulseTimer = new System.Timers.Timer(1000); m_PulseTimer.AutoReset = true; m_PulseTimer.Elapsed += new ElapsedEventHandler(m_PulseTimer_Elapsed); m_PulseTimer.Start(); m_Listener.Initialize(Settings.BINDING); }
private static void Main(string[] args) { /** * BOOTSTRAP - THIS IS WHERE THE SERVER STARTS UP * STEPS: * > Start logging system * > Load configuration * > Register packet handlers * > Start the login server service */ Logger.Initialize("log.txt"); Logger.InfoEnabled = true; //Disable for release. Logger.DebugEnabled = true; Logger.WarnEnabled = true; GonzoNet.Logger.OnMessageLogged += new GonzoNet.MessageLoggedDelegate(Logger_OnMessageLogged); LoginDataModel.Logger.OnMessageLogged += new LoginDataModel.MessageLoggedDelegate(Logger_OnMessageLogged); ProtocolAbstractionLibraryD.Logger.OnMessageLogged += new ProtocolAbstractionLibraryD.MessageLoggedDelegate(Logger_OnMessageLogged); PacketHandlers.Register((byte)PacketType.LOGIN_REQUEST, false, 0, new OnPacketReceive(LoginPacketHandlers.HandleLoginRequest)); PacketHandlers.Register((byte)PacketType.CHALLENGE_RESPONSE, true, 0, new OnPacketReceive(LoginPacketHandlers.HandleChallengeResponse)); PacketHandlers.Register((byte)PacketType.CHARACTER_LIST, true, 0, new OnPacketReceive(LoginPacketHandlers.HandleCharacterInfoRequest)); PacketHandlers.Register((byte)PacketType.CITY_LIST, true, 0, new OnPacketReceive(LoginPacketHandlers.HandleCityInfoRequest)); PacketHandlers.Register((byte)PacketType.CHARACTER_CREATE, true, 0, new OnPacketReceive(LoginPacketHandlers.HandleCharacterCreate)); PacketHandlers.Register((byte)PacketType.REQUEST_CITY_TOKEN, true, 0, new OnPacketReceive(LoginPacketHandlers.HandleCityTokenRequest)); PacketHandlers.Register((byte)PacketType.RETIRE_CHARACTER, true, 0, new OnPacketReceive(LoginPacketHandlers.HandleCharacterRetirement)); var Listener = new Listener(EncryptionMode.AESCrypto); Listener.Initialize(Settings.BINDING); NetworkFacade.ClientListener = Listener; NetworkFacade.CServerListener = new CityServerListener(EncryptionMode.AESCrypto); NetworkFacade.CServerListener.Initialize(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 2108)); var dbConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["MAIN_DB"]; DataAccess.ConnectionString = dbConnectionString.ConnectionString; //Test the DB connection. try { using (var db = DataAccess.Get()) { var testAccount = db.Accounts.GetByUsername("root"); if (testAccount == null) { db.Accounts.Create(new Account { AccountName = "root", Password = Account.GetPasswordHash("root", "root") }); } } } catch (Exception) { Console.WriteLine("Couldn't connect to database!"); Console.ReadKey(); Environment.Exit(0); } //64 is 100 in decimal. PacketHandlers.Register(0x64, false, 0, new OnPacketReceive(CityServerPacketHandlers.HandleCityServerLogin)); PacketHandlers.Register(0x67, false, 0, new OnPacketReceive(CityServerPacketHandlers.HandlePlayerOnlineResponse)); while(true) { Thread.Sleep(1000); } }
public Form1() { InitializeComponent(); /** * BOOTSTRAP - THIS IS WHERE THE SERVER STARTS UP * STEPS: * > Start logging system * > Load configuration * > Connect to the database and test the connection * > Register packet handlers * > Start the login server service */ Logger.Initialize("log.txt"); //Logger.InfoEnabled = true; //Disable for release. Logger.DebugEnabled = true; Logger.WarnEnabled = true; GonzoNet.Logger.OnMessageLogged += new GonzoNet.MessageLoggedDelegate(Logger_OnMessageLogged); LoginDataModel.Logger.OnMessageLogged += new LoginDataModel.MessageLoggedDelegate(Logger_OnMessageLogged); ProtocolAbstractionLibraryD.Logger.OnMessageLogged += new ProtocolAbstractionLibraryD.MessageLoggedDelegate(Logger_OnMessageLogged); var dbConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["MAIN_DB"]; DataAccess.ConnectionString = dbConnectionString.ConnectionString; /** TODO: Test the database **/ using (var db = DataAccess.Get()) { var testAccount = db.Accounts.GetByUsername("root"); if(testAccount == null){ db.Accounts.Create(new Account { AccountName = "root", Password = Account.GetPasswordHash("root", "root") }); } } PacketHandlers.Register((byte)PacketType.LOGIN_REQUEST, false, 0, new OnPacketReceive(LoginPacketHandlers.HandleLoginRequest)); PacketHandlers.Register((byte)PacketType.CHARACTER_LIST, true, 0, new OnPacketReceive(LoginPacketHandlers.HandleCharacterInfoRequest)); PacketHandlers.Register((byte)PacketType.CITY_LIST, true, 0, new OnPacketReceive(LoginPacketHandlers.HandleCityInfoRequest)); PacketHandlers.Register((byte)PacketType.CHARACTER_CREATE, true, 0, new OnPacketReceive(LoginPacketHandlers.HandleCharacterCreate)); PacketHandlers.Register((byte)PacketType.REQUEST_CITY_TOKEN, true, 0, new OnPacketReceive(LoginPacketHandlers.HandleCityTokenRequest)); var Listener = new Listener(); Listener.Initialize(Settings.BINDING); NetworkFacade.ClientListener = Listener; NetworkFacade.CServerListener = new CityServerListener(); NetworkFacade.CServerListener.Initialize(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 2108)); //64 is 100 in decimal. PacketHandlers.Register(0x64, false, 0, new OnPacketReceive(CityServerPacketHandlers.HandleCityServerLogin)); PacketHandlers.Register(0x65, false, 0, new OnPacketReceive(CityServerPacketHandlers.HandleKeyFetch)); PacketHandlers.Register(0x66, false, 3, new OnPacketReceive(CityServerPacketHandlers.HandlePulse)); }