コード例 #1
0
 private MessagesChatFull FetchFullChat(string address, bool superGroup)
 {
     //Classic check lock check pattern for concurrent access from all the methods
     if (_fullChat != null) return _fullChat;
     lock (_fullChatLock)
     {
         if (_fullChat != null) return _fullChat;
         using (var client = new FullClientDisposable(this))
         {
             if (!superGroup)
             {
                 _fullChat =
                     (MessagesChatFull)
                         TelegramUtils.RunSynchronously(
                             client.Client.Methods.MessagesGetFullChatAsync(new MessagesGetFullChatArgs
                             {
                                 ChatId = uint.Parse(address)
                             }));
             }
             else
             {
                 try
                 {
                     _fullChat =
                         (MessagesChatFull)
                             TelegramUtils.RunSynchronously(
                             client.Client.Methods.ChannelsGetFullChannelAsync(new ChannelsGetFullChannelArgs
                             {
                                 Channel = new InputChannel
                                 {
                                     ChannelId = uint.Parse(address),
                                     AccessHash = TelegramUtils.GetChannelAccessHash(_dialogs.GetChat(uint.Parse(address)))
                                 }
                             }));
                 }
                 catch (Exception e)
                 {
                     DebugPrint(">>>> get full channel exception " + e);
                 }
             }
             DebugPrint("#### fullchat " + ObjectDumper.Dump(_fullChat));
             _dialogs.AddUsers(_fullChat.Users);
             _dialogs.AddChats(_fullChat.Chats);
             return _fullChat;
         }
     }
 }
コード例 #2
0
 private Participants GetPartyParticipants(MessagesChatFull fullChat)
 {
     if (_participants != null)
     {
         return _participants;
     }
     lock (_participantsLock)
     {
         if (_participants != null)
         {
             return _participants;
         }
         var iChatFull = fullChat.FullChat;
         var chatFull = iChatFull as ChatFull;
         var channelFull = iChatFull as ChannelFull;
         if (chatFull != null)
         {
             var chatParticipants = chatFull.Participants as ChatParticipants;
             if (chatParticipants != null)
             {
                 DebugPrint("###### Party participants " + ObjectDumper.Dump(chatParticipants));
                 _participants = new Participants
                 {
                     Type = ParticipantsType.Chat,
                     ChatParticipants = chatParticipants.Participants
                 };
                 return _participants;
             }
         }
         if (channelFull != null)
         {
             var channelParticipants = GetChannelParticipants(channelFull, new ChannelParticipantsRecent());
             DebugPrint("###### Party participants " + ObjectDumper.Dump(channelParticipants));
             _participants = new Participants
             {
                 Type = ParticipantsType.Channel,
                 ChannelParticipants = channelParticipants
             };
             return _participants;
         }
     }
     return null;
 }
コード例 #3
0
 public Task PartyOptionsClosed()
 {
     return Task.Factory.StartNew(() =>
     {
         lock (_fullChatLock)
         {
             _fullChat = null;
             GC.Collect();
         }
         lock(_participantsLock)
         {
             _participants = null;
             GC.Collect();
         }
     });
 }