Example #1
0
 public void Unsubscribe(User user)
 {
     lock (_subscribers)
     {
         _subscribers.Remove(user);
     }
 }
Example #2
0
 public void Subscribe(User user, Action<string> onReceivedMessage)
 {
     lock (_subscribers)
     {
         _subscribers[user] = onReceivedMessage;
     }
 }
Example #3
0
        public ChatView(User myUser, User contactedUser)
            : base(new RootElement(contactedUser.Name), true)
        {
            _contactedUser = contactedUser;
            _myUser = myUser;

            _messageStorage = MessageStorage.Instanse;
            Root.Add(_section = new Section());
        }
Example #4
0
		private StyledStringElement CreateStringElement(User user)
		{
			var element = new StyledStringElement(user.Name, user.UserInfo) {Accessory = UITableViewCellAccessory.DisclosureIndicator};
			element.Tapped += () => OnUserSelected(user);
			user.UserInfoUpdated += (sender, args) =>
			{
				element.Value = user.UserInfo;
			    element.Caption = user.Name;
				Root.TableView.ReloadData();
			};
			return element;
		}
Example #5
0
        public void Add(CBPeripheral peripheral, string localNameKey)
        {
            if (_userList.Any(u => u.DeviceUuid.IsUuidEqual(peripheral.Identifier)))
            {
                return;
            }

            StoreInList(peripheral);
            var user = new User(localNameKey, peripheral.Identifier);
            _userList.Add(user);

            OnFoundUser(user);
        }
Example #6
0
 public List<MessageItem> GetMessages(User user)
 {
     return _storage.ContainsKey(user) ? _storage[user] : new List<MessageItem>();
 }
Example #7
0
 private void OnFoundUser(User user)
 {
     var handler = FoundUser;
     if (handler != null) handler(user);
 }
Example #8
0
        private UserStorage()
        {
            _userList = new List<User>();

            MyUser = new User("Me", UIDevice.CurrentDevice.IdentifierForVendor);
        }
Example #9
0
		private async void OnUserSelected(User user)
		{
			try
			{
				if (!user.IsConnected)
				{
					AlertDialog.ShowAlertProgress("Bluetooth", "Connecting User...");
					await _connectionManager.Connect(user.DeviceUuid);
					AlertDialog.CloseDialog();
				}

				user.NewMessagesCount = 0;
				ShowChatView(user);
			}
			catch (Exception)
			{
				AlertDialog.ShowAlertDialog("Failed to connect to user");   
			}
		}
Example #10
0
		private void AddUser(Section section, User user)
		{
			section.Add(CreateStringElement(user));
		}
Example #11
0
		private void ShowChatView(User user)
		{
			var chatController = new ChatRoomController(new ChatView(_userStorage.MyUser, user));
			chatController.Title = user.Name;

			var barButtonItem = new UIBarButtonItem(user.Status.ToString(), UIBarButtonItemStyle.Plain, null);
            chatController.NavigationItem.SetRightBarButtonItem(barButtonItem, true);

			NavigationController.PushViewController(chatController, true);
		}
Example #12
0
 public MessageItem(string message, User user, DateTime time)
 {
     Message = message;
     User = user;
     Time = time;
 }
 public PeripheralHandler GetPeripheralHandler(User user)
 {
     return _peripheralHandlerList.FirstOrDefault(handler => handler.Uuid.IsUuidEqual(user.DeviceUuid));
 }