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); }
//all bots are going to want to do the init handshake with the server public virtual void Initialize() { _client = new EOClient(CreatePacketProcessorActions()); if (!_client.ConnectToServer(_host, _port)) { throw new ArgumentException($"Bot {_index}: Unable to connect to server! Host={_host} Port={_port}"); } _api = new PacketAPI(_client); //todo: adapt to new networking architecture //InitData data; //if (!_api.Initialize(0, 0, 28, new HDSerialNumberService().GetHDSerialNumber(), 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; }