Ejemplo n.º 1
0
        private void mniEnter_Click(object sender, EventArgs e)
        {
            if (mniEnter.Text == "Login")
            {
                LoginFrm dlg = new LoginFrm(_serverIpv4, _serverPort, true);
                dlg.ShowDialog();
                _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
            {
                Text                        = "Offline";
                mniEnter.Text               = "Login";
                mniCreateRoom.Enabled       = false;
                mniConnectMyProfile.Enabled = false;
                _client.SendCommand(new CommandContainer(CommandType.ClientLogOff, new ProfileContainer(_client.UserName, _client.Password)));
                _client.Disconnect();
                _client = null;
                lstViwUsers.Items.Clear();
                ClearRoomItems();
                CloseRooms();
            }
        }
Ejemplo n.º 2
0
        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;
            }
        }