public AbstractCollection(IMeteor meteor, params string[] collectionNames) { _meteor = meteor; _meteor.ItemAdded += ProcessItemAdded; _meteor.ItemUpdated += ProcessItemUpdated; _meteor.ItemDeleted += ProcessItemDeleted; foreach (string collection in collectionNames) { _collections.Add(collection); } }
/// <summary> /// Initializes a new instance of the <see cref="T:RocketChatPCL.AbstractRocketChatClient"/> class. /// </summary> /// <param name="host">The host name of the rocket chat server</param> /// <param name="port">The port number of the rocket chat server</param> /// <param name="ssl">If set to <c>true</c> https and wss will be used.</param> /// <param name="restClient">The platform specific rest client implementation</param> /// <param name="meteor">The MeteorPCL implementation</param> public AbstractRocketChatClient(string host, int port, bool ssl, IRestClient restClient, IMeteor meteor) { _ssl = ssl; _host = host; _port = port; _meteor = meteor; _client = restClient; Users = new UserCollection(_meteor); Rooms = new RoomCollection(_meteor); Settings = new SettingsCollection(_meteor); Permissions = new PermissionsCollection(_meteor); }
public PermissionsCollection(IMeteor meteor) : base(meteor) { _permissionsByRole = new Dictionary <string, HashSet <Permission> >(); }
public Room(IMeteor meteor) { _meteor = meteor; }
public static Room Parse(IMeteor meteor, JObject m) { var room = new Room(meteor); if (m["_id"] != null) { room.Id = m["_id"].Value <string>(); } if (m["name"] != null) { room.Name = m["name"].Value <string>(); } if (m["t"] != null) { switch (m["t"].ToString()) { case "d": room.Type = RoomType.DirectMessage; break; case "p": room.Type = RoomType.PrivateGroup; break; case "c": room.Type = RoomType.PublicChannel; break; } } if (m["u"] != null) { room.Owner = User.Parse(m["u"] as JObject); } if (m["topic"] != null) { room.Topic = m["topic"].Value <string>(); } if (m["default"] != null) { room.Default = m["default"].Value <bool>(); } if (m["ro"] != null) { room.ReadOnly = m["ro"].Value <bool>(); } if (m["description"] != null) { room.Description = m["description"].Value <string>(); } room.MutedUsers = new List <string>(); if (m["muted"] != null) { foreach (var user in m["muted"] as JArray) { room.MutedUsers.Add(user.Value <string>()); } } if (m["_deletedAt"] != null) { room.DeletedAt = TypeUtils.ParseDateTime(m["_deletedAt"] as JObject); } return(room); }
public SettingsCollection(IMeteor meteor) : base(meteor) { }
public RoomCollection(IMeteor meteor) : base(meteor, "userChannels", "stream-notify-room", "stream-notify-user", "stream-room-messages") { }
public UserCollection(IMeteor meteor) : base(meteor, "users") { }
public static Message Parse(IMeteor meteor, JObject m) { Message message = new Message(meteor); if (m["_id"] != null) { message.Id = (m["_id"] as JValue).Value <string>(); } if (m["rid"] != null) { message.RoomId = (m["rid"] as JValue).Value <string>(); } if (m["t"] != null && m["t"] is JValue) { switch ((m["t"] as JValue).Value <string>()) { case "room_changed_topic": message.Type = MessageType.ROOM_CHANGED_TOPIC; break; case "uj": message.Type = MessageType.USER_JOINED; break; case "ul": message.Type = MessageType.USER_LEFT; break; case "au": message.Type = MessageType.ADDED_USER; break; case "message_pinned": message.Type = MessageType.MESSAGE_PINNED; break; default: message.Type = MessageType.MESSAGE; break; } } else { message.Type = MessageType.MESSAGE; } if (m["ts"] != null) { message.Created = TypeUtils.ParseDateTime(m["ts"] as JObject); } if (m["msg"] != null) { message.Text = (m["msg"] as JValue).Value <string>(); } if (m["_updatedAt"] != null) { message.UpdatedAt = TypeUtils.ParseDateTime(m["_updatedAt"] as JObject); } if (m["editedAt"] != null) { message.EditedAt = TypeUtils.ParseDateTime(m["editedAt"] as JObject); } if (m["editedBy"] != null) { message.EditedBy = User.Parse(m["editedBy"] as JObject); } message.Urls = new List <AttachedUrl>(); if (m["urls"] != null) { foreach (var url in m["urls"] as JArray) { message.Urls.Add(AttachedUrl.Parse(url as JObject)); } } message.Attachments = new List <Attachment>(); if (m["attachments"] != null) { foreach (var attachment in m["attachments"]) { message.Attachments.Add(Attachment.Parse(attachment as JObject)); } } if (m["alias"] != null) { message.Alias = m["alias"].Value <string>(); } if (m["avatar"] != null) { message.Avatar = m["avatar"].Value <string>(); } if (m["groupable"] != null) { message.Groupable = m["groupable"].Value <bool>(); } if (m["parseUrls"] != null) { message.ParseUrls = m["parseUrls"].Value <bool>(); } if (m["u"] != null) { message.User = User.Parse(m["u"] as JObject); } if (m["bot"] != null) { message.Bot = Bot.Parse(m["bot"] as JObject); } message.Reactions = new Dictionary <string, List <string> >(); if (m["reactions"] != null && m["reactions"] is JObject) { foreach (var reaction in (m["reactions"] as JObject)) { message.Reactions.Add(reaction.Key, new List <string>()); if (reaction.Value["usernames"] != null) { foreach (var user in reaction.Value["usernames"]) { message.Reactions[reaction.Key].Add(user.Value <string>()); } } } } return(message); }
public Message(IMeteor meteor) { _meteor = meteor; }