/// <summary> /// check what got added after previous callback /// </summary> private void CheckIncoming() { //need to look for newlines int index; while ((index = incoming.IndexOf('\n')) >= 0) { //one message segment String Message = incoming.Substring(0, index); if (Message.EndsWith("\r")) { Message = Message.Substring(0, index - 1); } messages.Enqueue(Message); incoming = incoming.Substring(index + 1); } while (receives.Count > 0 && messages.Count > 0) { RecInteraction goodreceive = receives.Dequeue(); string goodmessage = messages.Dequeue(); ThreadPool.QueueUserWorkItem(x => goodreceive.recvCB(goodmessage, null, goodreceive.payload)); } if (receives.Count > 0) { //bounded buffer. no DOSing byte[] buffer = new byte[1024]; ByteSocket.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, ReceivedBytes, buffer); } }
private void NextRec(RecInteraction swipe, bool saveInfo = true, bool isAutoSwipe = false) { _progress.Report(new LoadingProgress("Displaying next recommendation...")); ClearPhotos(); _progress.Report(new LoadingProgress("Swiping...")); bool isMatch = false; if (_recsEnum.Current.Swipe(swipe, out isMatch) && swipe == RecInteraction.Like) { MessageBox.Show("Out of likes!", "TinderPlus"); } if (isMatch) { MessageBox.Show("It's a match!", "TinderPlus"); } _progress.Report(null); _progress.Report(new LoadingProgress("Saving info...")); string id = _recsEnum.Current.User.ID; if (UserHistory.Add(id)) { for (int i = 0; i < 24; i += 2) { _historyWriter.WriteByte(Convert.ToByte(id.Substring(i, 2), 16)); } } if (saveInfo) { float score = 0; if (isAutoSwipe) { if (swipe == RecInteraction.Pass) { score = -0.99f; } else { score = 0.1f; } } else { switch (swipe) { case RecInteraction.Like: score = -0.15f; break; case RecInteraction.Pass: score = -0.49f; break; case RecInteraction.Super: score = 0.34f; break; } if (radUgly.Checked) { score -= 0.25f; } else if (radHot.Checked || radFun.Checked) { score += 0.25f; } else if (radMate.Checked) { score += 0.5f; } else if (radBigNo.Checked) { score -= 0.5f; } _progress.Report(null); } var infoPath = _curSavedPath + _recsEnum.Current.User.ID + ".json"; if (Directory.Exists(_curSavedPath) && File.Exists(infoPath)) { File.Copy( infoPath, @"E:\Programming\Tinder\" + _recsEnum.Current.User.Name + "_" + _recsEnum.Current.User.Birthday.ToString("yyMMdd") ); } else { API.SaveAllRelevantInfo(_recsEnum.Current, @"E:\Programming\Tinder\", score); } _progress.Report(null); if (Directory.Exists(_curTempPath)) { Directory.Delete(_curTempPath, true); } if (Directory.Exists(_curSavedPath)) { var files = Directory.GetFiles(_curSavedPath); if (files == null || !files.Any()) { Directory.Delete(_curSavedPath); } } } _recsEnum.MoveNext(); while (!_recsEnum.Current.User.Photos.Any()) { _recsEnum.MoveNext(); } _progress.Report(null); //DisplayRec(_recsEnum.Current); }