Exemple #1
0
 public CampfireChatClient(CampfireNetClient campfireNetClient, CampfireChatSettings campfireChatSettings, ChatRoomTable chatRoomTable, ChatMessageSender messageSender)
 {
     this.campfireChatSettings = campfireChatSettings;
     CampfireNetClient         = campfireNetClient;
     ChatRoomTable             = chatRoomTable;
     MessageSender             = messageSender;
 }
Exemple #2
0
        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);
        }
Exemple #3
0
        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;
            }
        }
Exemple #4
0
 public ChatRoomContext ConfigurePrivateChatRoom(IdentityHash hash, byte[] symmetricKey)
 {
     CampfireNetClient.IdentityManager.AddMulticastKey(hash, symmetricKey);
     return(ChatRoomTable.GetOrCreate(hash));
 }
Exemple #5
0
        public ChatRoomContext ConfigurePublicChatRoom(string name)
        {
            var roomHashBytes = Encoding.UTF8.GetBytes(name);

            return(ChatRoomTable.GetOrCreate(IdentityHash.GetFlyweight(CryptoUtil.GetHash(roomHashBytes))));
        }
Exemple #6
0
        public ChatRoomViewModel CreateChatRoomViewModelByIdentityHashAndSubscribe(IdentityHash chatroomIdentityHash, ChatMessageReceivedCallback messageReceivedCallback)
        {
            var chatRoomContext = ChatRoomTable.GetOrCreate(chatroomIdentityHash);

            return(chatRoomContext.CreateViewModelAndSubscribe(messageReceivedCallback));
        }
Exemple #7
0
 public ChatMessageSender(CampfireNetClient client, ChatRoomTable chatRoomTable)
 {
     this.client        = client;
     this.chatRoomTable = chatRoomTable;
 }