public void AddPacket(WorldPacket packet) { lock (this) { this._sendPacket = packet; } }
public void HandleMyTask(WorldPacket recvPacket) { if (recvPacket != null) { MyTask task = new MyTask { _id = recvPacket.ReadUInt32(), _publishTime = recvPacket.ReadUInt32(), _isRun = recvPacket.ReadUInt32() == 1 }; uint num = recvPacket.ReadUInt32(); for (uint i = 0; i < num; i++) { string str = recvPacket.ReadString(); string str2 = recvPacket.ReadString(); string str3 = recvPacket.ReadString(); string str4 = recvPacket.ReadString(); string str5 = recvPacket.ReadString(); TaskInfo info = new TaskInfo(str, str2, str3, str4, str5); task._taskItems.Add(info); } int num3 = recvPacket.ReadInt32(); int num4 = recvPacket.ReadInt32(); int num5 = 0; ArrayList areaClicks = new ArrayList(); num5 = 0; while (num5 < 0x1f) { areaClicks.Add((num3 & (((int) 1) << num5)) != 0); num5++; } while (num5 < 0x23) { areaClicks.Add((num4 & (((int) 1) << (num5 - 0x1f))) != 0); num5++; } task.SetAreaClick(areaClicks); ArrayList hourClicks = new ArrayList(); for (num5 = 0; num5 < 0x30; num5++) { uint num6 = recvPacket.ReadUInt32(); hourClicks.Add(num6); } task.SetHourClick(hourClicks); task._validClickCount = recvPacket.ReadUInt32(); task._invalidClickCount = recvPacket.ReadUInt32(); task._todayValidClickCount = recvPacket.ReadUInt32(); task._todayInvalidClickCount = recvPacket.ReadUInt32(); task._yesterdayValidClickCount = recvPacket.ReadUInt32(); task._yesterdayInvalidClickCount = recvPacket.ReadUInt32(); task.Note = recvPacket.ReadString(); this.AddTask(task); this.UpdateAccount(); } }
private void SendCryptPacket() { if (!this._Crypt.IsInitialisedSend()) { int a = new Random().Next(); WorldPacket packet = new WorldPacket(); packet.Initialize(5); packet.InputInt(a); this.SendCorePacket(packet); this._Crypt.InitialiseSend((uint) a); } }
private void SendAuthPacket() { WorldPacket packet = new WorldPacket(); int a = 0; string salt = LoginUtil.GenerateSalt(); string str2 = LoginUtil.GenerateKey(this._K, salt); packet.Initialize(3); packet.InputUInt32(this._accountID); packet.InputUInt32(this._accountTime); if ((this._accountTime == 0) && string.IsNullOrEmpty(this._K)) { a = 1; } packet.InputInt32(a); packet.InputString("1.0.0.37", 0x100); packet.InputString(salt, 0x40); packet.InputString(str2, 0x40); this.SendCorePacket(packet); }
private void ConnectError() { byte[] destinationArray = new byte[4]; uint num = 9; Array.Copy(BitConverter.GetBytes(num), 0, destinationArray, 0, 4); WorldPacket packet = new WorldPacket(4, destinationArray); lock (this._packets) { this._packets.Add(packet); } }
public void HandleEditAccount(WorldPacket recvPacket) { if (recvPacket == null) { return; } int num = recvPacket.ReadInt32(); if (num == 0) { this.LoginUtil.Account = recvPacket.ReadString(); this.LoginUtil.AccountID = recvPacket.ReadUInt32(); int num2 = recvPacket.ReadInt32(); this.LoginUtil.K = this.K; this.LoginUtil.AccountTime = 0; this.LoginUtil.SaveSetting(); this.UpdateAccount(); if (num2 != 0) { this.ConnectToServer(); return; } return; } string s = "修改用户信息失败"; switch (num) { case 11: s = s + "用户名有误,请尝试换一个用户名?"; break; case 7: s = s + "用户名或邮箱已经注册"; goto Label_00AB; case 10: s = s + "推荐人用户名错误"; goto Label_00AB; } Label_00AB: this.ShowAccountTip(s); }
public void GetTaskPacket(MyTask task, WorldPacket ms) { ms.InputInt(task._taskItems.Count); foreach (TaskInfo info in task._taskItems) { ms.InputString(info._param1, 0x20); ms.InputString(info._param2, 0x100); ms.InputString(info._param3, 0x100); ms.InputString(info._param4, 0x100); ms.InputString(info._param5, 0x100); } if ((task._HourClicks != null) && (task._HourClicks.Count == 0x30)) { for (int i = 0; i < 0x30; i++) { ms.InputUInt32((uint) task._HourClicks[i]); } } else { for (int j = 0; j < 0x30; j++) { ms.InputUInt32(0); } } int[] numArray = new int[2]; if ((task._AreaClicks != null) && (task._AreaClicks.Count == 0x23)) { for (int k = 0; k < 0x1f; k++) { numArray[0] |= ((bool) task._AreaClicks[k]) ? (((int) 1) << k) : 0; } for (int m = 0x1f; m < 0x23; m++) { numArray[1] |= ((bool) task._AreaClicks[m]) ? (((int) 1) << (m - 0x1f)) : 0; } } ms.InputInt(numArray[0]); ms.InputInt(numArray[1]); ms.InputString(task.Note, 0x40); }
private int HandleGatePlayerReg(WorldPacket recvPacket) { if ((recvPacket != null) && (recvPacket.ReadInt32() == 0)) { this.ResetLoginUser(); this._gateSession.GateSocket.Account = this._gateSession.Account = this.LoginUtil.Account = recvPacket.ReadString(); this._gateSession.GateSocket.AccountTime = this.LoginUtil.AccountTime = recvPacket.ReadUInt32(); this._gateSession.GateSocket.K = this.LoginUtil.K = string.Empty; this._gateSession.GateSocket.SendGateAuth(); this.ResetNetTime(); } return 0; }
public void SendGetLoginInfo(bool getTask = true) { WorldPacket packet = new WorldPacket(); packet.Initialize(11); if (getTask) { packet.InputUInt32(1); } else { packet.InputUInt32(0); } this.AddPacket(packet); }
public void SendCompletTask(uint taskID, int taskSteps) { WorldPacket packet = new WorldPacket(); packet.Initialize(0x19); packet.InputUInt32(taskID); packet.InputInt(taskSteps); this.AddPacket(packet); }
public void SendCheckAccountName(string account) { if (this.IsConnected()) { WorldPacket packet = new WorldPacket(); packet.Initialize(0x1b); packet.InputString(account, 0x20); this.AddPacket(packet); } else { WorldPacket packet2 = new WorldPacket(); packet2.Initialize(11); packet2.InputString(account, 0x20); this._gateSession.GateSocket.AddPacket(packet2); } }
public void SendAddTask(MyTask task) { WorldPacket ms = new WorldPacket(); ms.Initialize(13); this.GetTaskPacket(task, ms); this.AddPacket(ms); }
public void HandleStopTask(WorldPacket recvPacket) { if ((recvPacket != null) && (recvPacket.ReadInt32() == 0)) { uint taskID = recvPacket.ReadUInt32(); this.StopTasks(taskID); } }
public void HandleServerCheckAccount(WorldPacket recvPacket) { if (recvPacket != null) { int ret = recvPacket.ReadInt32(); if (this.CreateAccountForm != null) { this.CreateAccountForm.CheckAccount(ret); } } }
public int HandleServerAuth(WorldPacket recvPacket) { int num = 1; this._serverSession.Authed = false; if (recvPacket != null) { int code = recvPacket.ReadInt32(); if (code == 0) { num = 0; this.LoginUtil.Account = recvPacket.ReadString(); this._serverSession.Authed = true; this.UpdateAccount(); return num; } this.SetReLogin(code); this.ClearPackets(); } return num; }
private void HandleCheckAccount(WorldPacket recvPacket) { if (recvPacket != null) { int ret = recvPacket.ReadInt32(); if (this.CreateAccountForm != null) { this.CreateAccountForm.CheckAccount(ret); } } this.ClearPackets(); }
private int HandleGateAuth(WorldPacket recvPacket) { if (recvPacket != null) { int code = recvPacket.ReadInt32(); string str = string.Empty; int num2 = 0; if (code == 0) { uint accountID = recvPacket.ReadUInt32(); uint accountTime = recvPacket.ReadUInt32(); int num5 = recvPacket.ReadInt32(); for (int i = 0; i < num5; i++) { str = recvPacket.ReadString(); num2 = recvPacket.ReadInt32(); } this.IP = str; this.Port = num2; this.LoginUtil.LoginSuccess(accountID, this._gateSession.Account, accountTime, this.GateSession.GateSocket.K); this.Init2(); } else { this.SetReLogin(code); this.ClearPackets(); } } return 1; }
public void SendGetTask() { WorldPacket packet = new WorldPacket(); packet.Initialize(15); this.AddPacket(packet); }
private void HandleGatePlayerRegUser(WorldPacket recvPacket) { if (recvPacket == null) { return; } int num = recvPacket.ReadInt32(); if (num == 0) { this.LoginUtil.Account = recvPacket.ReadString(); this.LoginUtil.AccountID = recvPacket.ReadUInt32(); recvPacket.ReadInt32(); this.LoginUtil.K = this.K; this.LoginUtil.AccountTime = 0; this.LoginUtil.SaveSetting(); this.ResetLoginUser(); this.UpdateAccount(); return; } string s = "修改用户信息失败"; switch (num) { case 11: s = s + "用户名有误,请尝试换一个用户名?"; break; case 7: s = s + "用户名或邮箱已经注册"; goto Label_00A8; case 10: s = s + "推荐人用户名错误"; goto Label_00A8; } Label_00A8: this.ShowAccountTip(s); this.ClearPackets(); }
public void SendModifyAccount(string account, string email, string password, string phone, string referee) { this._K = client.LoginUtil.GenerateOrginalKey(account, password); if (this.IsConnected()) { WorldPacket packet = new WorldPacket(); packet.Initialize(0x1d); packet.InputString(account, 0x20); packet.InputString(email, 0x40); packet.InputString(this._K, 0x40); packet.InputString(phone, 0x40); packet.InputString(referee, 0x20); this.AddPacket(packet); } else { WorldPacket packet2 = new WorldPacket(); packet2.Initialize(9); packet2.InputString(account, 0x20); packet2.InputString(email, 0x40); packet2.InputString(this._K, 0x40); packet2.InputString(phone, 0x40); packet2.InputString(referee, 0x20); this._gateSession.GateSocket.AddPacket(packet2); } }
public void HandleCompleteTask(WorldPacket recvPacket) { if (recvPacket != null) { this.LoginUtil.Score = recvPacket.ReadUInt32(); this.LoginUtil.DayNetTaskScore = recvPacket.ReadUInt32(); this.LoginUtil.DayNetTaskCount = recvPacket.ReadUInt32(); this.UpdateAccount(); } }
public void SendModifyTask(MyTask task) { WorldPacket ms = new WorldPacket(); ms.Initialize(0x11); ms.InputUInt32(task._id); this.GetTaskPacket(task, ms); this.AddPacket(ms); }
public void SendPacket(WorldPacket packet) { this.SendCryptPacket(); this.SendAuthPacket(); this.SendCorePacket(packet); }
public void SendRemoveTask(uint taskID) { WorldPacket packet = new WorldPacket(); packet.Initialize(0x17); packet.InputUInt32(taskID); this.AddPacket(packet); }
private int HandleCrypt(WorldPacket recvPacket) { if (!this._Crypt.IsInitialisedRecv() && (recvPacket != null)) { uint seedRecv = recvPacket.ReadUInt32(); this.Crypt.InitialiseRecv(seedRecv); return 0; } return -1; }
public void SendStopTask(MyTask task) { WorldPacket packet = new WorldPacket(); packet.Initialize(0x13); packet.InputUInt32(task._id); this.AddPacket(packet); }
private void SendCorePacket(WorldPacket packet) { try { uint[] @in = new uint[2]; uint num = (uint) (packet.Length % 8L); num = (num == 0) ? 0 : (8 - num); for (uint i = 0; i < num; i++) { packet.InputByte(0); } uint length = (uint) packet.Length; @in[0] = length; @in[1] = packet.Opcode; this._Crypt.encryptSend(ref @in); this._writer.Write(@in[0]); this._writer.Write(@in[1]); for (uint j = 0; j < packet.Length; j += 8) { @in[0] = BitConverter.ToUInt32(packet.ToArray(), (int) j); @in[1] = BitConverter.ToUInt32(packet.ToArray(), ((int) j) + 4); this._Crypt.encryptSend(ref @in); this._writer.Write(@in[0]); this._writer.Write(@in[1]); } this._writer.Flush(); } catch (Exception) { } }
private void AddPacket(WorldPacket packet) { PacketProcessInfo info = new PacketProcessInfo(packet); this._packets.Add(info); }
private void ThreadFunc() { try { if (!string.IsNullOrEmpty(this._ip)) { this._client = new TcpClient(AddressFamily.InterNetwork); this._client.Connect(this._ip, this._port); this._networkStream = this._client.GetStream(); this._reader = new BinaryReader(this._networkStream); this._writer = new BinaryWriter(this._networkStream); this._threadRun = true; } else { Logger.Trace("连接网络服务器:IP为空"); this._threadRun = false; this.ConnectError(); } } catch (Exception exception) { Logger.Error(exception); this._threadRun = false; this._client = null; this.ConnectError(); } while (this._threadRun) { byte[] destinationArray = null; WorldPacket recvPacket = null; uint num = 0; uint op = 0; try { num = this._reader.ReadUInt32(); op = this._reader.ReadUInt32(); uint[] @in = new uint[] { num, op }; this._Crypt.decryptRecv(ref @in); num = @in[0]; op = @in[1]; if ((num >= 0) && (num < 0xa00000)) { if (num > 0) { destinationArray = new byte[num]; for (uint i = 0; i < num; i += 8) { @in[0] = this._reader.ReadUInt32(); @in[1] = this._reader.ReadUInt32(); this._Crypt.decryptRecv(ref @in); Array.Copy(BitConverter.GetBytes(@in[0]), 0L, destinationArray, (long) i, 4L); Array.Copy(BitConverter.GetBytes(@in[1]), 0L, destinationArray, (long) (i + 4), 4L); } recvPacket = new WorldPacket(op, destinationArray); } else { recvPacket = new WorldPacket(op); } } else { this._threadRun = false; } if (!this._threadRun) { break; } if (recvPacket != null) { if (recvPacket.Opcode == 6) { this.HandleCrypt(recvPacket); } else { lock (this._packets) { this._packets.Add(recvPacket); } } } } catch (Exception) { break; } if (!this._threadRun) { break; } } this._threadRun = false; if ((this._client != null) && this._client.Connected) { this._client.Close(); } this._client = null; this._connecting = false; }
private void HandleAccountInfo(WorldPacket recvPacket) { if (recvPacket != null) { uint num = 0; uint validClick = 0; uint invalidClick = 0; uint taskID = 0; uint todayValidClick = 0; uint todayInvalidClick = 0; uint yesterdayValidClick = 0; uint yesterdayInvalidClick = 0; this._loginUtil.Score = recvPacket.ReadUInt32(); this._loginUtil.DayConsumeScore = recvPacket.ReadUInt32(); this._loginUtil.DayCompleteTask = recvPacket.ReadUInt32(); this._loginUtil.DayNetTaskScore = recvPacket.ReadUInt32(); this._loginUtil.DayNetTaskCount = recvPacket.ReadUInt32(); this._loginUtil.ServerTasksCount = recvPacket.ReadUInt32(); num = recvPacket.ReadUInt32(); for (uint i = 0; i < num; i++) { taskID = recvPacket.ReadUInt32(); validClick = recvPacket.ReadUInt32(); invalidClick = recvPacket.ReadUInt32(); todayValidClick = recvPacket.ReadUInt32(); todayInvalidClick = recvPacket.ReadUInt32(); yesterdayValidClick = recvPacket.ReadUInt32(); yesterdayInvalidClick = recvPacket.ReadUInt32(); this.SetValidClick(taskID, validClick, invalidClick, todayValidClick, todayInvalidClick, yesterdayValidClick, yesterdayInvalidClick); } this._loginUtil.PublishTotalScore = recvPacket.ReadUInt32(); this._loginUtil.PublishTotalTask = recvPacket.ReadUInt32(); this._loginUtil.GetTotalScore = recvPacket.ReadUInt32(); this._loginUtil.GetTotalTask = recvPacket.ReadUInt32(); this._loginUtil.VipRemainDays = recvPacket.ReadUInt32(); this.UpdateAccount(); } }