Ejemplo n.º 1
0
        public IEnumerable <ChatInfoDto> GetChats(int count = 50)
        {
            Logger.Log.Info($"GET {Request.Method} {Request.RequestUri}");
            try
            {
                var viberChats       = new List <ChatInfoDto>();
                var chatInfoEntities = _chatInfoQuery.GetEntities()
                                       .Take(count)
                                       .ToList();

                foreach (var chatInfoEntity in chatInfoEntities)
                {
                    var viberChat = new ChatInfoDto
                    {
                        Id   = chatInfoEntity.Id,
                        Name = chatInfoEntity.Name
                    };
                    viberChats.Add(viberChat);
                }
                return(viberChats);
            }
            catch (Exception exception)
            {
                Logger.Log.Error(exception);
                throw;
            }
        }
Ejemplo n.º 2
0
        public static async Task JoinChatAsync()
        {
            await ExecuteProtected(async() =>
            {
                ChatInfoDto chat = await CHAT_CLIENT.GetChatInfo(ReadChatName());

                (int publ, int priv) = DIFFIE.GetKeys(chat.P, chat.G);
                JoinChatDto joinDto  = new JoinChatDto(chat.Name, LOGIN, publ);
                ChatInfoDto chatInfo = await CHAT_CLIENT.JoinChat(joinDto);

                Console.WriteLine($"Joined {chat.Name}, public: {publ}, private: {priv}\n");
                USER_CHAT_KEYS.Add(chat.Name, new UserChatKeys(chat, publ, priv));

                await OpenChatAsync(chat.Name);
            });
        }
Ejemplo n.º 3
0
        public static async Task CreateChatAsync()
        {
            await ExecuteProtected(async() =>
            {
                string name = ReadChatName();

                (int p, int g)       = DIFFIE.GetPG();
                (int publ, int priv) = DIFFIE.GetKeys(p, g);

                CreateChatDto createDto = new CreateChatDto(name, LOGIN, p, g, publ);
                ChatInfoDto chat        = await CHAT_CLIENT.CreateChat(createDto);

                Console.WriteLine($"Chat {chat.Name} created, public: {publ}, private: {priv}\n");
                USER_CHAT_KEYS.Add(chat.Name, new UserChatKeys(chat, publ, priv));

                await OpenChatAsync(chat.Name);
            });
        }
Ejemplo n.º 4
0
 public UserChatKeys(ChatInfoDto chat, int publicKey, int privateKey)
 {
     Chat       = chat;
     PublicKey  = publicKey;
     PrivateKey = privateKey;
 }