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; } }
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); }); }
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); }); }
public UserChatKeys(ChatInfoDto chat, int publicKey, int privateKey) { Chat = chat; PublicKey = publicKey; PrivateKey = privateKey; }