Пример #1
0
        /// <summary>
        /// Retreives the staff members from sparklr
        /// </summary>
        /// <returns>An Array of Staff members</returns>
        public async Task<User[]> GetStaffAsync()
        {
            SparklrResponse<SparklrSharp.JSONRepresentations.Get.UserMinimal[]> response = await webClient.GetJSONResponseAsync<SparklrSharp.JSONRepresentations.Get.UserMinimal[]>("staff");

            User[] staffMembers = new User[response.Response.Length];

            for (int i = 0; i < response.Response.Length; i++)
            {
                staffMembers[i] = await User.InstanciateUserAsync(response.Response[i].id, this);
            }

            return staffMembers;
        }
Пример #2
0
        /// <summary>
        /// Returns an instance of a streamn with mentions. Mentions are cached
        /// </summary>
        /// <param name="user">The user that is mentioned</param>
        /// <param name="conn">The connection on which to retreive the mentions</param>
        /// <returns></returns>
        public static async Task<Mentions> InstanciateMentionsAsync(User user, Connection conn)
        {
            if (!streamCache.ContainsKey(user.UserId))
            {
                Mentions m = new Mentions(user);

                Post[] initialPosts = await conn.GetMentionsAsync(user.UserId);

                foreach (Post p in initialPosts)
                    m.posts.Add(p);

                streamCache.Add(user.UserId, m);
            }

            return streamCache[user.UserId];
        }
Пример #3
0
 internal Conversation(User conversationPartner, Connection conn)
 {
     this.conn = conn;
     this.ConversationPartner = conversationPartner;
     NeedsRefresh = true;
 }
 /// <summary>
 /// Retreives (or creates) a conversation on the given connection. You can use this to handle conversations asynchronously
 /// </summary>
 /// <param name="conn"></param>
 /// <param name="u"></param>
 /// <returns></returns>
 public static Conversation GetConversationWith(this Connection conn, User u)
 {
     return new Conversation(u, conn);
 }
 /// <summary>
 /// Retreives the conversation with the given user on the given connection, this is a blocking call
 /// </summary>
 /// <param name="u">The conversation partner</param>
 /// <param name="conn">The connection on which to run the query</param>
 /// <returns></returns>
 public static IEnumerable<Message> ConversationWith(this Connection conn, User u)
 {
     return ConversationWith(conn, u.UserId);
 }
Пример #6
0
 /// <summary>
 /// Returns a stream of posts for the given user. Streams are cached.
 /// </summary>
 /// <param name="u">The user for which to retreive the posts</param>
 /// <param name="conn">The conenction on which to run the query</param>
 /// <returns></returns>
 public static Task<Stream> InstanciateStreamAsync(User u, Connection conn)
 {
     return InstanciateStreamAsync(u.UserId.ToString(), conn);
 }
 /// <summary>
 /// Retreives the stream for the given user
 /// </summary>
 /// <param name="conn"></param>
 /// <param name="u"></param>
 /// <returns></returns>
 public static Task<Stream> GetStreamAsync(this Connection conn, User u)
 {
     return Stream.InstanciateStreamAsync(u, conn);
 }
 /// <summary>
 /// Retreives mentions of a user on the given connection
 /// </summary>
 /// <param name="u">The user for which to retreive the mentions</param>
 /// <param name="conn">The connection on which the query is run</param>
 /// <returns>Mentions (cached)</returns>
 public static async Task<Mentions> GetMentionsAsync(this Connection conn, User u)
 {
     return await Mentions.InstanciateMentionsAsync(u, conn);
 }
Пример #9
0
        internal static User InstanciateUser(int userid, string name, string handle, long avatarid)
        {
            if(!userCache.ContainsKey(userid))
            {
                User u = new User(userid, name, handle, avatarid);
                userCache.Add(userid, u);
#if DEBUG
                if (System.Diagnostics.Debugger.IsAttached)
                    System.Diagnostics.Debug.WriteLine("Added user #{0} to cache", u.UserId);
#endif
            }

            return userCache[userid];
        }
Пример #10
0
 internal Task<bool> SendMessageAsync(string content, User recipient)
 {
     return SendMessageAsync(content, recipient.UserId);
 }
Пример #11
0
 internal Notification(int id, User from, User to, NotificationType type, long timestamp, string body, string action)
 {
     this.Id = id;
     this.From = from;
     this.To = to;
     this.Type = type;
     this.TimeStamp = timestamp;
     this.Body = body;
     this.Action = action;
 }
Пример #12
0
 private Mentions(User u)
 {
     this.User = u;
 }
 internal UserIdentifiedEventArgs(User u)
 {
     IdentifiedUser = u;
 }