Connect() public method

Connects to the login server.
public Connect ( GonzoNet.LoginArgsContainer LoginArgs ) : void
LoginArgs GonzoNet.LoginArgsContainer Arguments used for login. Can be null.
return void
Beispiel #1
0
        public VMClientDriver(string hostName, int port, OnStateChangeDelegate callback)
        {
            Commands = new Queue<VMNetCommandBodyAbstract>();
            Client = new NetworkClient(hostName, port, EncryptionMode.NoEncryption, true);

            Client.OnConnected += Client_OnConnected;
            Client.OnDisconnect += Client_OnDisconnect;
            OnStateChange += callback;
            Client.Connect(null);

            TickBuffer = new Queue<VMNetTick>();
        }
Beispiel #2
0
        private VM VMHook; //should probably always backreference the VM anyways, but just used by disconnect

        #endregion Fields

        #region Constructors

        public VMClientDriver(string hostName, int port, OnStateChangeDelegate callback)
        {
            Commands = new Queue<VMNetCommandBodyAbstract>();
            Client = new NetworkClient(hostName, port, EncryptionMode.NoEncryption, true);

            Client.OnConnected += Client_OnConnected;
            Client.OnDisconnect += Client_OnDisconnect;
            OnStateChange += callback;
            Client.Connect(null);

            GlobalLink = null; //transactions only performed by server. transaction results
            //are passed back to the clients as commands (for the primitive, at least)

            TickBuffer = new Queue<VMNetTick>();
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            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)
            {
                Console.WriteLine("Couldn't find a ServerConfig.ini file!");
                Console.ReadLine();
                Environment.Exit(0);
            }

            //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;

            NetworkFacade.NetworkListener = new Listener(EncryptionMode.AESCrypto);
            //Remove a player from the current session when it disconnects.
            NetworkFacade.NetworkListener.OnDisconnected += new OnDisconnectedDelegate(NetworkFacade.CurrentSession.RemovePlayer);

            m_LoginClient = new NetworkClient("127.0.0.1", 2108, EncryptionMode.AESCrypto, true);
            m_LoginClient.OnNetworkError += new NetworkErrorDelegate(m_LoginClient_OnNetworkError);
            m_LoginClient.OnConnected += new OnConnectedDelegate(m_LoginClient_OnConnected);
            m_LoginClient.Connect(null);

            //Adds all houses from DB to the current session.
            using(DataAccess db = DataAccess.Get())
            {
                IQueryable<Character> Chars = db.Characters.GetAllCharsWithHouses();

                var CharsWithHouses = Chars.Where(x => x.HouseHouse != null);

                foreach(Character Char in CharsWithHouses)
                    NetworkFacade.CurrentSession.AddHouse(Char, Char.HouseHouse);
            }

            NetworkFacade.NetworkListener.Initialize(Settings.BINDING);
            m_NancyHost = new NancyHost(new Uri("http://173.248.136.133:8888/city/"));
            m_NancyHost.Start();

            try
            {
                NetworkFacade.CurrentTerrain.Initialize("East Jerome");
                NetworkFacade.CurrentTerrain.LoadContent();
                NetworkFacade.CurrentTerrain.GenerateCityMesh();
            }
            catch(Exception e)
            {
                Console.WriteLine("Couldn't load elevation data!");
                Console.WriteLine(e.ToString());
                Console.ReadLine();
                Environment.Exit(0);
            }

            m_VM = new VM.VM();
            m_VM.Init();

            while (true)
            {
                m_VM.Update();
                Thread.Sleep(1000);
            }
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        /// <summary>
        /// Reconnects to a CityServer.
        /// </summary>
        public void Reconnect(ref NetworkClient Client, CityInfo SelectedCity, LoginArgsContainer LoginArgs)
        {
            Client.Disconnect();

            if (LoginArgs.Enc == null)
            {
                System.Diagnostics.Debug.WriteLine("LoginArgs.Enc was null!");
                LoginArgs.Enc = new GonzoNet.Encryption.AESEncryptor(Convert.ToBase64String(PlayerAccount.Hash));
            }
            else if (LoginArgs.Username == null || LoginArgs.Password == null)
            {
                System.Diagnostics.Debug.WriteLine("LoginArgs.Username or LoginArgs.Password was null!");
                LoginArgs.Username = PlayerAccount.Username;
                LoginArgs.Password = Convert.ToBase64String(PlayerAccount.Hash);
            }

            Client.Connect(LoginArgs);
        }