public IMSession GetIMLogFrom(string id, int first, int last = -1) { if (IMLog.ContainsKey(id)) { IMSession resp = IMSession.partialIMSession(IMLog[id], first, last); return(resp); } return(null); }
public static IMSession partialIMSession(IMSession session, int first, int last) { IMSession sesh = new IMSession(); sesh.user_id = session.user_id; sesh.user_name = session.user_name; if (session.messages.Count > first) { int l = last - first; if (l < 0 || last < 0 || (l + first) >= session.messages.Count) { l = session.messages.Count - first; } int read = session.messages.Count - (first + l); sesh.messages = session.messages.GetRange(first, l); } else { sesh.messages = null; } return(sesh); }
public static IMSession partialIMSession(IMSession session,int first,int last) { IMSession sesh = new IMSession(); sesh.user_id = session.user_id; sesh.user_name = session.user_name; if (session.messages.Count > first) { int l = last - first; if (l < 0 || last < 0 || (l + first) >= session.messages.Count) l = session.messages.Count - first; int read = session.messages.Count - (first + l); sesh.messages = session.messages.GetRange(first, l); } else sesh.messages = null; return sesh; }