public async Task <AccountReply> CreateAccount(ICreateAccountParameters parameters) { var createAccountPacket = new PacketBuilder(PacketFamily.Account, PacketAction.Create) .AddShort(1337) //eoserv doesn't .AddByte(42) //validate these values .AddBreakString(parameters.AccountName) .AddBreakString(parameters.Password) .AddBreakString(parameters.Location) .AddBreakString(parameters.Location) .AddBreakString(parameters.Email) .AddBreakString(Dns.GetHostName()) .AddBreakString(_hdSerialNumberService.GetHDSerialNumber()) .Build(); var response = await _packetSendService.SendEncodedPacketAndWaitAsync(createAccountPacket); if (IsInvalidResponse(response)) { throw new EmptyPacketReceivedException(); } return((AccountReply)response.ReadShort()); }
public async Task <IInitializationData> BeginHandshake() { var stupidHash = _hashService.StupidHash(new Random().Next(6, 12)); var hdSerialNumber = _hdSerialNumberService.GetHDSerialNumber(); var packet = new PacketBuilder(PacketFamily.Init, PacketAction.Init) .AddThree(stupidHash) .AddChar(_configurationProvider.VersionMajor) .AddChar(_configurationProvider.VersionMinor) .AddChar(_configurationProvider.VersionBuild) .AddChar(112) .AddChar((byte)hdSerialNumber.Length) .AddString(hdSerialNumber) .Build(); var responsePacket = await _packetSendService.SendRawPacketAndWaitAsync(packet); if (IsInvalidInitPacket(responsePacket)) { throw new EmptyPacketReceivedException(); } return(_initPacketTranslator.TranslatePacket(responsePacket)); }