public CampfireChatClient(CampfireNetClient campfireNetClient, CampfireChatSettings campfireChatSettings, ChatRoomTable chatRoomTable, ChatMessageSender messageSender) { this.campfireChatSettings = campfireChatSettings; CampfireNetClient = campfireNetClient; ChatRoomTable = chatRoomTable; MessageSender = messageSender; }
public static CampfireChatClient Create(CampfireNetClient campfireNetClient) { var campfireChatSettings = new CampfireChatSettings { LocalFriendlyName = "Anonymous" }; var chatRoomTable = new ChatRoomTable(); var messageSender = new ChatMessageSender(campfireNetClient, chatRoomTable); var campfireChatClient = new CampfireChatClient(campfireNetClient, campfireChatSettings, chatRoomTable, messageSender); chatRoomTable.SetChatMessageSender(messageSender); chatRoomTable.SetCampfireChatClient(campfireChatClient); campfireChatClient.Initialize(); return(campfireChatClient); }
private void HandleClientMessageReceivedOrSent(MessageReceivedEventArgs e) { Console.WriteLine("Starting handle"); var dto = CampfireChatSerializer.Deserialize(e); switch (dto.GetType().Name) { case nameof(ChatMessageDto): var message = (ChatMessageDto)dto; Console.WriteLine("Calling handle now"); ChatRoomTable.GetOrCreate(message.BroadcastMessage.DestinationId).HandleMessageReceived(message); break; } }
public ChatRoomContext ConfigurePrivateChatRoom(IdentityHash hash, byte[] symmetricKey) { CampfireNetClient.IdentityManager.AddMulticastKey(hash, symmetricKey); return(ChatRoomTable.GetOrCreate(hash)); }
public ChatRoomContext ConfigurePublicChatRoom(string name) { var roomHashBytes = Encoding.UTF8.GetBytes(name); return(ChatRoomTable.GetOrCreate(IdentityHash.GetFlyweight(CryptoUtil.GetHash(roomHashBytes)))); }
public ChatRoomViewModel CreateChatRoomViewModelByIdentityHashAndSubscribe(IdentityHash chatroomIdentityHash, ChatMessageReceivedCallback messageReceivedCallback) { var chatRoomContext = ChatRoomTable.GetOrCreate(chatroomIdentityHash); return(chatRoomContext.CreateViewModelAndSubscribe(messageReceivedCallback)); }
public ChatMessageSender(CampfireNetClient client, ChatRoomTable chatRoomTable) { this.client = client; this.chatRoomTable = chatRoomTable; }