Пример #1
0
        public void UpdateChannels()
        {
            if (!ShouldUpdate())
            {
                return;
            }

            connection.SendMessage(Constants.ClientCommands.PublicChannelList);
            connection.SendMessage(Constants.ClientCommands.PrivateChannelList);
            lastUpdate = DateTime.Now;
        }
Пример #2
0
        private void CommandReceived(IDictionary <string, object> command)
        {
            var type = command.Get(Constants.Arguments.Type);

            if (type == null)
            {
                return;
            }

            try
            {
                var useSlash = type.ToLower().Equals(type);
                Logging.Log((useSlash ? "/" : "") + type, "user cmnd");
                Logging.LogObject(command);
                Logging.Log();

                CommandHandler handler;
                commands.TryGetValue(type, out handler);
                if (handler == null)
                {
                    connection.SendMessage(command);
                    return;
                }

                handler(command);
            }
            catch (Exception ex)
            {
                ex.Source = "Message Daemon, command received";
                Exceptions.HandleException(ex);
            }
        }
Пример #3
0
        public void RemoveChannel(string name, bool force, bool isServer)
        {
            Log("Removing Channel " + name);

            if (cm.CurrentChannels.Any(param => param.Id == name))
            {
                var temp = cm.CurrentChannels.FirstByIdOrNull(name);
                temp.Description = null;

                var index = cm.CurrentChannels.IndexOf(temp);
                RequestNavigate(cm.CurrentChannels[index - 1].Id);

                Dispatcher.Invoke(
                    (Action)(() => cm.CurrentChannels.Remove(temp)));

                if (isServer)
                {
                    return;
                }

                object toSend = new { channel = name };
                connection.SendMessage(toSend, Commands.ChannelLeave);
            }
            else if (cm.CurrentPms.Any(param => param.Id == name))
            {
                var temp  = cm.CurrentPms.FirstByIdOrNull(name);
                var index = cm.CurrentPms.IndexOf(temp);
                RequestNavigate(index != 0 ? cm.CurrentPms[index - 1].Id : "Home");

                cm.CurrentPms.Remove(temp);
            }
            else if (force)
            {
                object toSend = new { channel = name };
                connection.SendMessage(toSend, Commands.ChannelLeave);
            }
            else
            {
                throw new ArgumentOutOfRangeException(nameof(name), "Could not find the channel requested to remove");
            }
        }