Esempio n. 1
0
 public ChatRoomViewModel CreateViewModelAndSubscribe(ChatMessageReceivedCallback messageReceivedCallback)
 {
     lock (synchronization) {
         var previousMessages = messages.ToList().Select(kvp => kvp.Key).ToList();
         var viewModel        = new ChatRoomViewModel(this, previousMessages, messageReceivedCallback);
         viewModels.AddOrThrow(viewModel);
         return(viewModel);
     }
 }
Esempio n. 2
0
        public ChatRoomViewModel CreateChatRoomViewModelByIdentityHashAndSubscribe(IdentityHash chatroomIdentityHash, ChatMessageReceivedCallback messageReceivedCallback)
        {
            var chatRoomContext = ChatRoomTable.GetOrCreate(chatroomIdentityHash);

            return(chatRoomContext.CreateViewModelAndSubscribe(messageReceivedCallback));
        }
Esempio n. 3
0
        public ChatRoomViewModel CreateChatRoomViewModelByNameAndSubscribe(string chatroomName, ChatMessageReceivedCallback messageReceivedCallback)
        {
            var destinationHash = IdentityHash.GetFlyweight(CryptoUtil.GetHash(Encoding.UTF8.GetBytes(chatroomName)));

            return(CreateChatRoomViewModelByIdentityHashAndSubscribe(destinationHash, messageReceivedCallback));
        }
Esempio n. 4
0
 public ChatRoomViewModel(ChatRoomContext context, List <ChatMessageDto> initialMessages, ChatMessageReceivedCallback messageReceivedCallback)
 {
     Context                 = context;
     InitialMessages         = initialMessages;
     MessageReceivedCallback = messageReceivedCallback;
 }