Ejemplo n.º 1
0
        public void Kick(ServerClient client, string reason = null)
        {
            if (!(this is LobbyChannel))
            {
                LobbyChannel lobby = ChannelRepository.Instance.GetLobby();
                if (lobby == null)
                {
                    return;
                }

                if (client.Channel.Equals(lobby))
                {
                    return;
                }

                TalkyChannel oldChannel = client.Channel;
                client.JoinChannel(lobby, false);

                if (reason != null)
                {
                    oldChannel.BroadcastMessage(client.Username + " was kicked from the channel (" + reason + ").");
                }
                oldChannel.BroadcastMessage(client.Username + " was kicked from the channel.");
            }
        }
Ejemplo n.º 2
0
        public void RestoreFromDB()
        {
            MySqlConnection connection = MySqlConnector.GetConnection();

            if (connection != null)
            {
                MySqlCommand command = new MySqlCommand("SELECT `channel_name`, `lobby_type`, `locked` FROM `channels` ORDER BY `id` ASC", connection);
                command.Prepare();
                try
                {
                    MySqlDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        string       channelName  = reader.GetString("channel_name");
                        string       lobbyString  = reader.GetString("lobby_type");
                        string       lockedString = reader.GetString("locked");
                        TalkyChannel restoredChannel;

                        if (lobbyString.Equals("true"))
                        {
                            restoredChannel = new LobbyChannel(channelName);
                        }
                        else if (lockedString.Equals("true"))
                        {
                            restoredChannel = new SystemChannel(channelName, true);
                        }
                        else
                        {
                            restoredChannel = new ClientChannel(channelName, true);
                        }

                        Store(restoredChannel, false);
                    }
                }
                catch
                {
                    Console.WriteLine("channels table: could not SELECT in RestoreFromDB ");
                }
                connection.Close();
            }
        }