public void Unsubscribe(User user) { lock (_subscribers) { _subscribers.Remove(user); } }
public void Subscribe(User user, Action<string> onReceivedMessage) { lock (_subscribers) { _subscribers[user] = onReceivedMessage; } }
public ChatView(User myUser, User contactedUser) : base(new RootElement(contactedUser.Name), true) { _contactedUser = contactedUser; _myUser = myUser; _messageStorage = MessageStorage.Instanse; Root.Add(_section = new Section()); }
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; }
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); }
public List<MessageItem> GetMessages(User user) { return _storage.ContainsKey(user) ? _storage[user] : new List<MessageItem>(); }
private void OnFoundUser(User user) { var handler = FoundUser; if (handler != null) handler(user); }
private UserStorage() { _userList = new List<User>(); MyUser = new User("Me", UIDevice.CurrentDevice.IdentifierForVendor); }
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"); } }
private void AddUser(Section section, User user) { section.Add(CreateStringElement(user)); }
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); }
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)); }