private void login_button_Click(object sender, EventArgs e) { //start connection this.serverConnection = new ServerConnection(); UserName = username.Text; PacketLogin loginPacket = new PacketLogin() { username = username.Text, password = password.Text }; this.serverConnection.WritePacket(loginPacket); Packet _packet = this.serverConnection.ReadPacket(); PacketLoginResponse login = _packet as PacketLoginResponse; if (login != null) { if (login.loginOk) { this.Hide(); new Client(this.serverConnection, username.Text, login.number).Show(); Console.WriteLine("good login"); } else { Console.WriteLine("failed login"); } } }
private void loginButton_Click(object sender, EventArgs e) { try { //MessageBox.Show("check1"); client = new TcpClient(Info.GetIp().ToString(), Info.Port); stream = client.GetStream(); } catch (Exception) { MessageBox.Show("No connection with the server"); Thread.CurrentThread.Abort(); } //MessageBox.Show("check2"); formatter = new BinaryFormatter(); formatter.Serialize(stream, new PacketMonitor()); //MessageBox.Show("check3"); Packet loginPacket = new PacketLogin() { username = userNameTextBox.Text, password = passwordTextBox.Text }; formatter.Serialize(stream, loginPacket); //MessageBox.Show("check4"); PacketLoginResponse response = (PacketLoginResponse)formatter.Deserialize(stream); loginResponse(response.loginOk, response.dir); //loginResponse(true); }
private void button1_Click(object sender, EventArgs e) { Packet loginPacket = new PacketLogin() { username = "******", password = "******" }; BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, loginPacket); }
// for UI buttons public void SendConnect() { SetupServer(); PacketLogin login = new PacketLogin { Email = loginWindow.getEmail(), Pass = loginWindow.getPass() }; Byte[] loginBA = login.ToByteArray(); sendPacket((int)Cmd.CmdLogin, loginBA); managerUI.SetStateWaiting(); }
void OnLogin(PacketLogin packet) { }
public override void HandleTypeClient(ClientPacket packet) { Response = new PangyaBinaryWriter(); switch (ServerType) { case ServerTypeEnum.Unknown: break; case ServerTypeEnum.Login: { var packetID = (LoginPacketEnumResponse)packet.Id; if (packetID == LoginPacketEnumResponse.PLAYER_CONNECTION) { PacketLogin.Handle(this, packetID, packet); } else if (packetID != LoginPacketEnumResponse.PLAYER_CONNECTION && Login.PangyaVersion == EnumPangyaVersion.US) { var packetold = packet; packet = new ClientPacket(packetold.Message, GetKey); packetID = (LoginPacketEnumResponse)packet.Id; PacketLogin.Handle(this, packetID, packet); } else if (packetID != LoginPacketEnumResponse.PLAYER_CONNECTION && Login.PangyaVersion == EnumPangyaVersion.TH) { var packetold = packet; var packets = packetold.GetSubPackets(packetold.Message, GetKey); if (packets.Count > 1) { for (int i = 0; i < packets.Count; i++) { packet = packets[i]; packetID = (LoginPacketEnumResponse)packet.Id; PacketLogin.Handle(this, packetID, packet); } } else if (packets.Count == 1) { packet = packets.First(); packetID = (LoginPacketEnumResponse)packet.Id; PacketLogin.Handle(this, packetID, packet); } } } break; case ServerTypeEnum.Game: { var packetID = (GamePacketEnumResponse)packet.Id; if (packetID == GamePacketEnumResponse.PLAYER_CONNECTION) { PacketGame.Handle(this, packetID, packet); } else if (packetID != GamePacketEnumResponse.PLAYER_CONNECTION) { var packetold = packet; packet = new ClientPacket(packetold.Message, GetKey); packetID = (GamePacketEnumResponse)packet.Id; PacketGame.Handle(this, packetID, packet); } Commands.SetPlayer(this); } break; case ServerTypeEnum.Message: { var packetID = (MessengerResponseEnum)packet.Id; PacketMessenger.Handle(this, packetID, packet); } break; default: break; } }