Example #1
0
		//all bots are going to want to do the init handshake with the server
		public virtual void Initialize()
		{
			_client = new EOClient();
			if (!_client.ConnectToServer(_host, _port))
				throw new ArgumentException(string.Format("Bot {0}: Unable to connect to server! Host={1} Port={2}", _index, _host, _port));
			_api = new PacketAPI(_client);

			InitData data;
			if (!_api.Initialize(0, 0, 28, EOLib.HDDSerial.GetHDDSerial(), out data))
				throw new TimeoutException(string.Format("Bot {0}: Failed initialization handshake with server!", _index));
			_client.SetInitData(data);

			if (!_api.ConfirmInit(data.emulti_e, data.emulti_d, data.clientID))
				throw new TimeoutException(string.Format("Bot {0}: Failed initialization handshake with server!", _index));

			if (!_api.Initialized || !_client.ConnectedAndInitialized || data.ServerResponse != InitReply.INIT_OK)
				throw new InvalidOperationException(string.Format("Bot {0}: Invalid response from server or connection failed! Must receive an OK reply.", _index));

			_initialized = true;
		}
Example #2
0
        public EOBot(int index, string host, int port)
        {
            m_index = index + 1;

            m_client = new EOClient();
            if (!m_client.ConnectToServer(host, port))
                throw new ArgumentException();
            m_api = new PacketAPI(m_client);

            InitData data;
            if (!m_api.Initialize(0, 0, 28, EOLib.Win32.GetHDDSerial(), out data))
                throw new TimeoutException();
            m_client.SetInitData(data);

            if (!m_api.ConfirmInit(data.emulti_e, data.emulti_d, data.clientID))
                throw new TimeoutException();

            if (!m_api.Initialized || !m_client.ConnectedAndInitialized || data.ServerResponse != InitReply.INIT_OK)
                throw new InvalidOperationException();

            m_terminationEvent = new AutoResetEvent(false);
        }