Exemplo n.º 1
0
        void HandleMessageDeleted(MessageDeleted messageDeleted)
        {
            Task.Factory
            .StartNew(() =>
            {
                var allQueues = Machines.SelectMany(m => m.Queues).ToArray();

                // update involved queues if they have been loaded
                var message     = messageDeleted.MessageThatWasDeleted;
                var sourceQueue =
                    allQueues.FirstOrDefault(
                        q => q.QueuePath.Equals(message.QueuePath, StringComparison.InvariantCultureIgnoreCase));

                return(new
                {
                    SourceQueue = sourceQueue,
                    Message = message,
                });
            })
            .ContinueWith(a =>
            {
                var result = a.Result;

                result.SourceQueue.Remove(result.Message);
            }, Context.UiThread);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Will be fired when the ApiWrapper reports that a message was deleted
 /// </summary>
 /// <param name="deletedMessage"></param>
 internal Task OnMessageDeletedAsync(ChatMessage deletedMessage)
 {
     LoggerFactory.CreateLogger(GetType().FullName).LogTrace($"Message deleted: {deletedMessage.Content})");
     return(MessageDeleted != null
         ? MessageDeleted.Invoke(deletedMessage)
         : Task.CompletedTask);
 }
Exemplo n.º 3
0
        public async Task OnMessageDelete(Cacheable <IMessage, ulong> message, ISocketMessageChannel channel)
        {
            var method = new MessageDeleted(Client, Config, MessageCache, HttpClient, LoggingService);
            await method.ProcessAsync(message, channel).ConfigureAwait(false);

            IncrementEventHandle("MessageDeleted");
        }
Exemplo n.º 4
0
 /// <summary>
 /// Constructs a new <see cref="BaseSocketClientAbstraction"/> around an existing <see cref="WebSocket.BaseSocketClient"/>.
 /// </summary>
 /// <param name="baseSocketClient">The value to use for <see cref="WebSocket.BaseSocketClient"/>.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="baseSocketClient"/>.</exception>
 protected BaseSocketClientAbstraction(BaseSocketClient baseSocketClient)
     : base(baseSocketClient)
 {
     baseSocketClient.ChannelCreated         += x => ChannelCreated?.InvokeAsync(x.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.ChannelDestroyed       += x => ChannelDestroyed?.InvokeAsync(x.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.ChannelUpdated         += (x, y) => ChannelUpdated?.InvokeAsync(x.Abstract(), y.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.CurrentUserUpdated     += (x, y) => CurrentUserUpdated?.InvokeAsync(x.Abstract(), y.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.GuildAvailable         += x => GuildAvailable?.InvokeAsync(x.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.GuildMembersDownloaded += x => GuildMembersDownloaded?.InvokeAsync(x.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.GuildMemberUpdated     += (x, y) => GuildMemberUpdated?.InvokeAsync(x.Abstract(), y.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.GuildUnavailable       += x => GuildUnavailable?.InvokeAsync(x.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.GuildUpdated           += (x, y) => GuildUpdated?.InvokeAsync(x.Abstract(), y.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.JoinedGuild            += x => JoinedGuild?.InvokeAsync(x.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.LeftGuild             += x => LeftGuild?.InvokeAsync(x.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.MessageReceived       += x => MessageReceived?.InvokeAsync(x.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.MessageUpdated        += (x, y, z) => MessageUpdated?.InvokeAsync(x.Abstract(), y.Abstract(), z.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.MessageDeleted        += (x, y) => MessageDeleted?.InvokeAsync(x.Abstract(), y.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.ReactionAdded         += (x, y, z) => ReactionAdded?.InvokeAsync(x.Abstract(), y.Abstract(), z.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.ReactionRemoved       += (x, y, z) => ReactionRemoved?.InvokeAsync(x.Abstract(), y.Abstract(), z.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.ReactionsCleared      += (x, y) => ReactionsCleared?.InvokeAsync(x.Abstract(), y.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.RecipientAdded        += x => RecipientAdded?.InvokeAsync(x.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.RecipientRemoved      += x => RecipientRemoved?.InvokeAsync(x.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.RoleCreated           += x => RoleCreated?.InvokeAsync(x.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.RoleDeleted           += x => RoleDeleted?.InvokeAsync(x.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.RoleUpdated           += (x, y) => RoleUpdated?.InvokeAsync(x.Abstract(), y.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.UserBanned            += (x, y) => UserBanned?.InvokeAsync(x.Abstract(), y.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.UserIsTyping          += (x, y) => UserIsTyping?.InvokeAsync(x.Abstract(), y.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.UserJoined            += x => UserJoined?.InvokeAsync(x.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.UserLeft              += x => UserLeft?.InvokeAsync(x.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.UserUnbanned          += (x, y) => UserUnbanned?.InvokeAsync(x.Abstract(), y.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.UserUpdated           += (x, y) => UserUpdated?.InvokeAsync(x.Abstract(), y.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.UserVoiceStateUpdated += (x, y, z) => UserVoiceStateUpdated?.InvokeAsync(x.Abstract(), y.Abstract(), z.Abstract()) ?? Task.CompletedTask;
     baseSocketClient.VoiceServerUpdated    += x => VoiceServerUpdated?.InvokeAsync(x.Abstract()) ?? Task.CompletedTask;
 }
Exemplo n.º 5
0
 private async Task DiscordShardedClientOnMessageDeleted(Cacheable <IMessage, ulong> arg1, ISocketMessageChannel arg2)
 {
     if (MessageDeleted != null)
     {
         await MessageDeleted.Invoke(this, arg1, arg2).ConfigureAwait(false);
     }
 }
Exemplo n.º 6
0
        public void RegisterEvents()
        {
            connection.On <ChatListModel>("NewChat", (chat) =>
            {
                NewChat?.Invoke(chat);
            });

            connection.On <MessageModel>("ReceiveMessage", (message) =>
            {
                message.IsMyMessage = false;
                NewCompanionMessage?.Invoke(message);
                if (!Client.Notifications.Any(x => String.Equals(message.ChatId, x)) &&
                    !Properties.UserSettings.Default.AllNotifications)
                {
                    Notify(message);
                }
            });

            connection.On <MessageModel>("MessageDeleted", (message) =>
            {
                MessageDeleted?.Invoke(message);
            });

            connection.On <MessageModel>("MessageUpdated", (message) =>
            {
                MessageUpdated?.Invoke(message);
            });
        }
Exemplo n.º 7
0
 private void When(MessageDeleted evt)
 {
     if (_quackers.Contains(evt.Deleter))
     {
         _quackers.Remove(evt.Deleter);
         IsDeleted = true;
     }
 }
Exemplo n.º 8
0
        public void DeleteMessage(ISmtp4devMessage message)
        {
            ISmtp4devMessage deletedMessage;

            if (_messages.TryRemove(message.Id, out deletedMessage))
            {
                MessageDeleted?.Invoke(this, new Smtp4devMessageEventArgs(deletedMessage));
            }
        }
    public MessageDeletedEvent(
        [JsonProperty(Required = Required.Always)]
        MessageDeleted message,

        [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
        HashId?serverId
        ) : base(serverId, message)
    {
    }
Exemplo n.º 10
0
        public static NewStreamMessage CreateMessageDeletedMessage(string streamId, Guid messageId)
        {
            var messageDeleted = new MessageDeleted {
                StreamId = streamId, MessageId = messageId
            };
            var json = SimpleJson.SerializeObject(messageDeleted);

            return(new NewStreamMessage(Guid.NewGuid(), MessageDeletedMessageType, json));
        }
Exemplo n.º 11
0
        public void DeleteMessage(ISmtp4devMessage message)
        {
            lock (_syncRoot)
            {
                _database.Delete(message);
                _database.Commit();
            }

            MessageDeleted?.Invoke(this, new Smtp4devMessageEventArgs(message));
        }
Exemplo n.º 12
0
 private void OnMessageDeleted(int messageId, int chatId, bool forAll, string author)
 {
     MessageDeleted?.Invoke(this, new MessageDeletedEventArgs()
     {
         MessageId     = messageId,
         ChatId        = chatId,
         DeletedForAll = forAll,
         Author        = author
     });
 }
Exemplo n.º 13
0
        public void Delete(IEventPublisher eventPublisher, UserId userId)
        {
            if (!_projection.Quackers.Contains(userId))
            {
                return;
            }


            var evt = new MessageDeleted(_projection.Id, userId);

            eventPublisher.Publish(evt);
        }
Exemplo n.º 14
0
        public async Task OnMessageDelete(Cacheable <IMessage, ulong> message, ISocketMessageChannel channel)
        {
            if (!CanProcessEvent("MessageDeleted"))
            {
                return;
            }

            var method = new MessageDeleted(Client, Config, MessageCache, HttpClient, AppLogger);
            await method.ProcessAsync(message, channel).ConfigureAwait(false);

            EventPostProcess("MessageDeleted");
        }
Exemplo n.º 15
0
        public static MessageDeleted AddMessageDeletedEventHandler <T>(
            this RoomWatcher <T> rw,
            Action <DeletedMessage> callback)
            where T : IWebSocket
        {
            callback.ThrowIfNull(nameof(callback));

            var eventProcessor = new MessageDeleted();

            eventProcessor.OnEvent += callback;

            rw.EventRouter.AddProcessor(eventProcessor);

            return(eventProcessor);
        }
Exemplo n.º 16
0
        public static MessageDeleted AddMessageDeletedEventHandler <T>(
            this RoomWatcher <T> rw,
            Action <Chat.User, int> callback)
            where T : IWebSocket
        {
            callback.ThrowIfNull(nameof(callback));

            var eventProcessor = new MessageDeleted();

            eventProcessor.OnEvent += md =>
            {
                var deletedBy = new Chat.User(rw.Host, md.DeletedBy, rw.Auth);

                callback(deletedBy, md.MessageId);
            };

            rw.EventRouter.AddProcessor(eventProcessor);

            return(eventProcessor);
        }
 public void Handle(MessageDeleted evt)
 {
     _timelineMessageRepository.Delete(evt.MessageId);
 }
        void OnEvent(string eventname, int seq, JsonNode data)
        {
            sequence = seq;
            switch (eventname)
            {
            case "READY":
                gatewayversion = data.SelectValue <int>("v");
                sessionid      = data.SelectValue <string>("session_id");
                OnConnected();
                break;

            case "RESUMED":
                OnConnected();
                break;

            case "INVALID_SESSION":
                Disconnect(1021, "Authentication failure", /*data.SelectValue<bool>("d")*/ false);
                break;

            case "CHANNEL_CREATE":
                ChannelCreated?.Invoke(JSON.Serializer.Read <Channel>(data));
                break;

            case "CHANNEL_UPDATE":
                ChannelUpdated?.Invoke(JSON.Serializer.Read <Channel>(data));
                break;

            case "CHANNEL_DELETE":
                ChannelDeleted?.Invoke(JSON.Serializer.Read <Channel>(data));
                break;

            case "CHANNEL_PINS_UPDATED":
                ChannelPinUpdated?.Invoke(data.SelectValue <string>("channel_id"));
                break;

            case "MESSAGE_CREATE":
                MessageCreated?.Invoke(JSON.Serializer.Read <Message>(data));
                break;

            case "MESSAGE_UPDATE":
                MessageUpdated?.Invoke(JSON.Serializer.Read <Message>(data));
                break;

            case "MESSAGE_DELETE":
                MessageDeleted?.Invoke(data.SelectValue <string>("channel_id"), data.SelectValue <string>("id"));
                break;

            case "MESSAGE_DELETE_BULK":
                MessagesDeleted?.Invoke(data.SelectValue <string>("channel_id"), data.SelectValue <string[]>("ids"));
                break;

            case "GUILD_CREATE":
                GuildCreated?.Invoke(JSON.Serializer.Read <Guild>(data));
                break;

            case "GUILD_UPDATE":
                GuildUpdated?.Invoke(JSON.Serializer.Read <Guild>(data));
                break;

            case "GUILD_DELETE":
                GuildDeleted?.Invoke(JSON.Serializer.Read <UnavailableGuild>(data));
                break;

            case "GUILD_BAN_ADD":
                UserBanned?.Invoke(JSON.Serializer.Read <GuildUser>(data));
                break;

            case "GUILD_BAN_REMOVED":
                UserUnbanned?.Invoke(JSON.Serializer.Read <GuildUser>(data));
                break;

            case "GUILD_EMOJIS_UPDATE":
                EmojisUpdated?.Invoke(data.SelectValue <string>("guild_id"), JSON.Serializer.Read <Emoji[]>(data["emojis"]));
                break;

            case "GUILD_INTEGRATIONS_UPDATE":
                GuildIntegrationsUpdated?.Invoke(data.SelectValue <string>("guild_id"));
                break;

            case "GUILD_MEMBER_ADD":
                GuildMemberAdded?.Invoke(data.SelectValue <string>("guild_id"), JSON.Serializer.Read <GuildMember>(data));
                break;

            case "GUILD_MEMBER_REMOVE":
                GuildMemberRemoved?.Invoke(data.SelectValue <string>("guild_id"), JSON.Serializer.Read <User>(data));
                break;

            case "GUILD_MEMBER_UPDATE":
                GuildMemberUpdated?.Invoke(data.SelectValue <string>("guild_id"), JSON.Serializer.Read <Role[]>(data["roles"]), JSON.Serializer.Read <User>(data["user"]), data.SelectValue <string>("nick"));
                break;

            case "GUILD_MEMBERS_CHUNK":
                GuildMembersChunk?.Invoke(data.SelectValue <string>("guild_id"), JSON.Serializer.Read <GuildMember[]>(data["members"]));
                break;

            case "GUILD_ROLE_CREATE":
                GuildRoleCreated?.Invoke(data.SelectValue <string>("guild_id"), JSON.Serializer.Read <Role>(data["role"]));
                break;

            case "GUILD_ROLE_UPDATE":
                GuildRoleUpdated?.Invoke(data.SelectValue <string>("guild_id"), JSON.Serializer.Read <Role>(data["role"]));
                break;

            case "GUILD_ROLE_DELETE":
                GuildRoleDeleted?.Invoke(data.SelectValue <string>("guild_id"), data.SelectValue <string>("role_id"));
                break;

            case "MESSAGE_REACTION_ADD":
                MessageReactionAdded?.Invoke(data.SelectValue <string>("user_id"), data.SelectValue <string>("channel_id"), data.SelectValue <string>("message_id"), JSON.Serializer.Read <Emoji>(data["emoji"]));
                break;

            case "MESSAGE_REACTION_REMOVE":
                MessageReactionRemoved?.Invoke(data.SelectValue <string>("user_id"), data.SelectValue <string>("channel_id"), data.SelectValue <string>("message_id"), JSON.Serializer.Read <Emoji>(data["emoji"]));
                break;

            case "MESSAGE_REACTION_REMOVE_ALL":
                MessageReactionRemovedAll?.Invoke(data.SelectValue <string>("channel_id"), data.SelectValue <string>("message_id"));
                break;

            case "PRESENCE_UPDATE":
                PresenceUpdated?.Invoke(JSON.Serializer.Read <PresenceUpdate>(data));
                break;

            case "TYPING_START":
                TypingStarted?.Invoke(data.SelectValue <string>("guild_id"), data.SelectValue <string>("user_id"), data.SelectValue <int>("timestamp").ToDateTime());
                break;

            case "USER_UPDATE":
                UserUpdated?.Invoke(JSON.Serializer.Read <User>(data));
                break;

            case "VOICE_STATE_UPDATE":
                VoiceStateUpdated?.Invoke(JSON.Serializer.Read <VoiceState>(data));
                break;

            case "VOICE_SERVER_UPDATE":
                VoiceServerUpdated?.Invoke(data.SelectValue <string>("token"), data.SelectValue <string>("guild_id"), data.SelectValue <string>("endpoint"));
                break;

            case "WEBHOOKS_UPDATE":
                WebhooksUpdated?.Invoke(data.SelectValue <string>("guild_id"), data.SelectValue <string>("channel_id"));
                break;

            default:
                Logger.Warning(this, $"'{eventname}' event not handled", data.ToString());
                break;
            }
        }
Exemplo n.º 19
0
        private void SubscribeToEvents()
        {
            _subscriptions.Apply(x => x.Dispose());
            _subscriptions.Clear();

            #region Channel

            _subscriptions.Add(_connection.On <ChannelSummaryResponse>(ClientEvents.ChannelUpdated,
                                                                       channel =>
            {
                ChannelUpdated?.Invoke(channel);
            }));

            _subscriptions.Add(_connection.On <Guid>(ClientEvents.ChannelClosed,
                                                     channelId =>
            {
                ChannelClosed?.Invoke(channelId);
            }));

            #endregion

            #region Message

            _subscriptions.Add(_connection.On <MessageResponse>(ClientEvents.MessageAdded,
                                                                message =>
            {
                MessageAdded?.Invoke(message);
            }));

            _subscriptions.Add(_connection.On <MessageResponse>(ClientEvents.MessageUpdated,
                                                                message =>
            {
                MessageUpdated?.Invoke(message);
            }));

            _subscriptions.Add(_connection.On <Guid, Guid>(ClientEvents.MessageDeleted,
                                                           (deletedMessageId, channelId) =>
            {
                MessageDeleted?.Invoke(deletedMessageId, channelId);
            }));

            _subscriptions.Add(_connection.On <Guid>(ClientEvents.LastReadMessageChanged,
                                                     channelId =>
            {
                LastReadMessageUpdated?.Invoke(channelId);
            }));

            #endregion

            #region Member

            _subscriptions.Add(_connection.On <ChannelSummaryResponse>(ClientEvents.MemberJoined,
                                                                       (channel) =>
            {
                MemberJoined?.Invoke(channel);
            }));

            _subscriptions.Add(_connection.On <Guid>(ClientEvents.MemberLeft,
                                                     (channelId) =>
            {
                MemberLeft?.Invoke(channelId);
            }));

            _subscriptions.Add(_connection.On <MemberSummaryResponse, Guid>(ClientEvents.MemberDeleted,
                                                                            (member, channelId) =>
            {
                MemberDeleted?.Invoke(member, channelId);
            }));

            #endregion
        }
Exemplo n.º 20
0
 private async Task MessageDeletedAsync(Cacheable <IMessage, ulong> message, ISocketMessageChannel channel)
 {
     MessageDeleted?.Invoke(message, channel);
 }
Exemplo n.º 21
0
 private void OnMessageDeleted(JsonMessageDeleted arg)
 => MessageDeleted?.Invoke(this, new MessageDeleted(arg, this));
Exemplo n.º 22
0
 private void OnMessageDeleted(object sender, MessageDeleted e)
 => _messenger.Send(new MessageDeletedMessage(e.ChannelId, e.MessageId));
Exemplo n.º 23
0
 private void When(MessageDeleted evt)
 {
     IsDeleted = true;
 }
Exemplo n.º 24
0
        void parseJson(object sender, string json)
        {
            Logger.LogMsg("Recieved: " + json);
            var packet = new Packet(json);

            if (packet.Id == PacketId.NewMessage)
            {
                var msg = new Message();
                msg.FromJson(packet.Information);

                Form.Invoke(new Action(() =>
                {
                    NewMessage?.Invoke(this, msg);
                }));
            }
            else if (packet.Id == PacketId.GiveIdentity)
            {
                var usr = new User();
                usr.FromJson(packet.Information);
                this.CurrentUser = usr;

                Form.Invoke(new Action(() =>
                {
                    IdentityKnown?.Invoke(this, usr);
                }));
            }
            else if (packet.Id == PacketId.UserUpdate)
            {
                var usr = new User();
                usr.FromJson(packet.Information);
                Form.Invoke(new Action(() =>
                {
                    UserUpdate?.Invoke(this, usr);
                }));
            }
            else if (packet.Id == PacketId.UserLeft)
            {
                var usr = new User();
                usr.FromJson(packet.Information);
                Form.Invoke(new Action(() =>
                {
                    UserDisconnected?.Invoke(this, usr);
                }));
            }
            else if (packet.Id == PacketId.SetMonitorState)
            {
                var state = packet.Information["state"].ToObject <bool>();
                Form.Invoke(new Action(() =>
                {
                    SetMonitorState?.Invoke(this, state);
                }));
            }
            else if (packet.Id == PacketId.Disconnect)
            {
                this.Close();
            }
            else if (packet.Id == PacketId.MessageDeleted)
            {
                var id = packet.Information["id"].ToObject <uint>();
                Form.Invoke(new Action(() =>
                {
                    MessageDeleted?.Invoke(this, id);
                }));
            }
            else if (packet.Id == PacketId.ImageNeedSlice)
            { // Server needs us to send the slice.
                var id        = packet.Information["id"].ToObject <uint>();
                var shiftedId = (uint)0;
                if (packet.Information.TryGetValue("originalId", out var val))
                {
                    shiftedId = id;
                    id        = val.ToObject <uint>();
                }
                var sliceNum = packet.Information["slice"].ToObject <int>();
                if (Common.Images.TryGetValue(id, out var image))
                {
                    if (shiftedId > 0)
                    { // move it into the new location, remove old one.
                        Common.Images[shiftedId] = image;
                    }
                    var slice = image.Slices[sliceNum];
                    var jobj  = new JObject(packet.Information);
                    jobj["done"] = (sliceNum == image.Slices.Count - 1);
                    jobj["data"] = slice;
                    var pongPacket = new Packet(PacketId.ImageSlice, jobj);
                    Send(pongPacket.ToString());
                    Form.Invoke(new Action(() =>
                    {
                        UploadStatus?.Invoke(this, new UploadStatusEvent(image, sliceNum));
                    }));
                }
            }
            else if (packet.Id == PacketId.ImageInitialInformation)
            {
                var image = new Classes.Image();
                image.FromJson(packet.Information);
                if (Common.TryGetImage(image.Id, out var existingImage))
                {
                    if (existingImage.Slices.Count == image.MaximumSlices)
                    { // We already have this image, so we dont need to download it
                        Form.Invoke(new Action(() =>
                        {
                            NewImageUploaded?.Invoke(this, existingImage);
                        }));
                        return;
                    }
                }
                Common.AddImage(image);
                var jobj = new JObject();
                jobj["id"]    = image.Id;
                jobj["slice"] = 0;
                var response = new Packet(PacketId.ImageNeedSlice, jobj);
                Send(response.ToString());
            }
            else if (packet.Id == PacketId.ImageSlice)
            {
                var id       = packet.Information["id"].ToObject <uint>();
                var sliceNum = packet.Information["slice"].ToObject <int>();
                var done     = packet.Information["done"].ToObject <bool>();
                var content  = packet.Information["data"].ToObject <string>();
                if (Common.TryGetImage(id, out var image))
                {
                    image.SetSlice(sliceNum, content);
                    if (done)
                    {
                        Form.Invoke(new Action(() =>
                        {
                            NewImageUploaded?.Invoke(this, image);
                        }));
                    }
                    else
                    {
                        var jobj = new JObject();
                        jobj["id"]    = image.Id;
                        jobj["slice"] = sliceNum + 1;
                        var pongPacket = new Packet(PacketId.ImageNeedSlice, jobj);
                        Send(pongPacket.ToString());
                        Form.Invoke(new Action(() =>
                        {
                            Form.pbProgressBar.Maximum = image.MaximumSlices;
                            Form.pbProgressBar.Value   = sliceNum;
                            Form.pbProgressBar.Tag     = $"Downloading image '{image.Name}'; {sliceNum}/{image.MaximumSlices} {((int)(sliceNum + 1 / image.MaximumSlices + 1))}";
                        }));
                    }
                }
            }
        }
Exemplo n.º 25
0
        public event Func <Task> Ready; // New

        internal async Task OnMessageDeleted(Cacheable <IMessage, ulong> message, ISocketMessageChannel channel) => await(MessageDeleted?.Invoke(message, channel) ?? Task.CompletedTask);
Exemplo n.º 26
0
 private Task MessageDeletedAsync(Cacheable <IMessage, ulong> message, ISocketMessageChannel channel)
 {
     MessageDeleted?.Invoke(message, channel);
     return(Task.CompletedTask);
 }