private void CommandReceived(object sender, CommandEventArgs e) { var msg = string.Empty; switch (e.Command.CommandType) { case CommandType.UserAlreadyExists: msg = "The User name is already exists !"; break; case CommandType.InvalidCredentials: msg = "Inavlid User name and/or Password !"; break; case CommandType.UserAlreadyConnected: msg = "The User name is already connected !"; break; case CommandType.ValidCredentials: _canClose = true; Close(); break; } if (e.Command.CommandType != CommandType.ValidCredentials) { frmPopup popup = new frmPopup(PopupSkins.SmallInfoSkin); popup.ShowPopup("Error", msg, 300, 2000, 2000); _client.Disconnect(); SetEnablity(true); } }
private void mniSignup_Click(object sender, EventArgs e) { LoginFrm dlg = new LoginFrm(_serverIpv4, _serverPort, false); dlg.ShowDialog(); if (_client != null) { if (_client.Connected) { frmPopup popup = new frmPopup(PopupSkins.SmallInfoSkin); popup.ShowPopup("Warning", string.Format("Disconnected user {0} !", _client.UserName), 300, 2000, 2000); _client.SendCommand(new CommandContainer(CommandType.ClientLogOff, new ProfileContainer(_client.UserName, _client.Password))); } Text = "Offline"; _client.Disconnect(); lstViwUsers.Items.Clear(); ClearRoomItems(); CloseRooms(); } _client = dlg.Client; if (_client.Connected) { _client.CommandReceived += new CommandReceivedEventHandler(client_CommandReceived); _client.SendCommand(new CommandContainer(CommandType.RequestClientList, null)); _client.SendCommand(new CommandContainer(CommandType.RequestRoomList, null)); Text = "Online : " + _client.UserName; mniEnter.Text = "Log Off"; mniCreateRoom.Enabled = true; mniConnectMyProfile.Enabled = true; } else { _client = null; } }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { currentClient.Disconnect(); }