public void Test00ReadInbox() { bool rc = SetupTwoPlusTwo.Forum.CheckPMs(0, 1, null, (page, errMessage, cookie) => { Console.WriteLine("{0} {1} {2}", page.TotalMessages, page.UnreadCount, page.Name); for (int i = 0; i < page.MessagesThisPage; i++) { PMHeader header = page[i]; Console.WriteLine("{0}: {1}", header.Sender, header.FirstLine); SetupTwoPlusTwo.Forum.ReadPM(header.Id, null, (id, pm, cookie2) => { } ); } } ); }
PMHeader ReadPMHeader(FileStream fs) { PMHeader header = new PMHeader(); BinaryReader br = new BinaryReader(fs); header.signature = br.ReadInt32(); header.signature2 = br.ReadInt32(); header.unknown = br.ReadBytes(52); header.unknown2 = br.ReadInt16(); header.numFields = br.ReadInt16(); return header; }
void PollPostsPMs() { List <PrivateMessage> pms = new List <PrivateMessage>(); _posts.Clear(); _readingPosts = true; _thread.ReadPages(_url, _pageStart, Int32.MaxValue, null); _forum.CheckPMs(0, 1, null, (folderpage, errMessage, cookie) => { for (int i = 0; i < folderpage.MessagesThisPage; i++) { PMHeader header = folderpage[i]; if ((_minTime <= header.Timestamp) && (_maxTime >= header.Timestamp) && (header.Id > _lastPMProcessed)) { _forum.ReadPM(header.Id, null, (id, pm, cake) => { pms.Add(pm); }); } } } ); while (_readingPosts) { System.Threading.Thread.Sleep(50); } String msg = String.Empty; List <CorralEvent> actions = new List <CorralEvent>(); Int32 lastPost = 0; foreach (var post in _posts) { if (post.PostNumber <= _lastPostProcessed) { continue; } if ((post.Time < _minTime) || (post.Time > _maxTime)) { continue; } msg += String.Format("{0} {1}:\r{2}", post.Time, post.Poster.Name, post.Content); lastPost = Math.Max(lastPost, post.PostNumber); CorralEvent action = PostToAction(post); actions.Add(action); } if (lastPost > _lastPostProcessed) { _lastPostProcessed = lastPost; } Int32 lastPMId = 0; foreach (var pm in pms) { if (pm.Id <= _lastPMProcessed) { continue; } msg += String.Format("{0} {1}: {2}\r{3}", pm.TimeStamp, pm.From, pm.Title, pm.Content); lastPMId = Math.Max(lastPMId, pm.Id); CorralEvent action = PMToAction(pm); actions.Add(action); } if (lastPMId > _lastPMProcessed) { _lastPMProcessed = lastPMId; } actions.Sort((x, y) => { int rc = x.TimeStamp.CompareTo(y.TimeStamp); if (rc == 0) { // same timestamp. rc = x.Action.CompareTo(y.Action); if (rc == 0) { rc = x.Id.CompareTo(y.Id); } } return(rc); }); CorralEvents oActions = new CorralEvents(actions); try { OnPlayerActions(oActions); } catch (Exception) { // don't sweat it. Writing clients is hard. } }