public async Task Subscribe() { // Subscribe to typing notifications. await _meteor.Subscribe("stream-notify-room", new object[] { Id + "/typing", false }); // Subscribe to delete message notifications await _meteor.Subscribe("stream-notify-room", new object[] { Id + "/deleteMessage", false }); // Subscribe to the room message notifications await _meteor.Subscribe("stream-room-messages", new object[] { Id, false }); Debug.WriteLine("Subscribed to Room {0} ({1})", Name, Id); }
/// <summary> /// Connect to the rocket chat server with the specified username and password. /// </summary> /// <returns>True if the connection is successful and false otherwise</returns> /// <param name="username">The username used to log into rocket chat.</param> /// <param name="password">The password used to log into rocket chat.</param> public async Task <bool> Connect(string username, string password) { await GetRemoteVersion(_host, _port, _ssl); // TODO: Check that the version is compatible. var login = await DoLogin(username, password); if (!login) { return(false); } await _meteor.Subscribe("stream-notify-user", new object[] { _userId + "/message", false }); await _meteor.Subscribe("stream-notify-user", new object[] { _userId + "/otr", false }); await _meteor.Subscribe("stream-notify-user", new object[] { _userId + "/webrtc", false }); await _meteor.Subscribe("stream-notify-user", new object[] { _userId + "/notification", false }); await _meteor.Subscribe("stream-notify-user", new object[] { _userId + "/subscriptions-changed", false }); await _meteor.Subscribe("stream-notify-user", new object[] { _userId + "/rooms-changed", false }); _meteor.MessageReceived += (message) => Debug.WriteLine("Message received: {0}", message); // Prepopulate the system with some meta-data from the server // Including the current list of users rooms/subscriptions/permissions and the server settings. await Rooms.Initialize(_userId, TypeUtils.UnixEpoch); await Settings.Initialize(_userId, TypeUtils.UnixEpoch); await Permissions.Initialize(_userId, TypeUtils.UnixEpoch); await _meteor.Subscribe("userData"); await _meteor.Subscribe("activeUsers"); return(true); }