protected virtual void CloseHUD(IntPtr windowHandle) { Task.Run(() => { Task.Delay(DelayToProcessHands * 2).Wait(); var args = new TableClosedEventArgs(windowHandle.ToInt32()); eventAggregator.GetEvent <TableClosedEvent>().Publish(args); }); }
public void CloseHUD(int windowHandle) { var args = new TableClosedEventArgs(windowHandle); importer.eventAggregator.GetEvent <TableClosedEvent>().Publish(args); }
/// <summary> /// Processes packets in the buffer /// </summary> protected void ProcessBuffer() { var packetManager = ServiceLocator.Current.GetInstance <IPacketManager <PokerMasterPackage> >(); var handBuilder = ServiceLocator.Current.GetInstance <IHandBuilder>(); var tableWindowProvider = ServiceLocator.Current.GetInstance <IEmulatorService>(); var handHistoriesToProcess = new ConcurrentDictionary <long, List <HandHistoryData> >(); var connectionsService = ServiceLocator.Current.GetInstance <INetworkConnectionsService>(); connectionsService.SetLogger(Logger); var detectedTableWindows = new HashSet <IntPtr>(); var userRooms = new Dictionary <long, Tuple <long, IntPtr> >(); while (!cancellationTokenSource.IsCancellationRequested) { try { if (!packetBuffer.TryTake(out CapturedPacket capturedPacket)) { Task.Delay(NoDataDelay).Wait(); continue; } if (!packetManager.TryParse(capturedPacket, out IList <PokerMasterPackage> packages)) { continue; } foreach (var package in packages) { if (!IsAllowedPackage(package)) { continue; } if (package.Cmd == PackageCommand.Cmd_SCLoginRsp) { ParseLoginPackage <SCLoginRsp>(package, x => x?.UserInfo, x => x?.EncryptKey); continue; } if (package.Cmd == PackageCommand.Cmd_SCUploadVerifyCodeRsp) { ParseLoginPackage <SCUploadVerifyCodeRsp>(package, x => x?.UserInfo, x => x?.EncryptKey); continue; } if (package.Cmd == PackageCommand.Cmd_SCLoginThirdPartyRsp) { ParseLoginPackage <SCLoginThirdPartyRsp>(package, x => x?.UserInfo, x => x?.EncryptKey); continue; } if (package.Cmd == PackageCommand.Cmd_SCLeaveGameRoomRsp || package.Cmd == PackageCommand.Cmd_SCLeaveMTTGameRoom || package.Cmd == PackageCommand.Cmd_SCLeaveSNGGameRoomRsp) { ParsePackage <SCLeaveGameRoomRsp>(package, body => { if (userRooms.ContainsKey(package.Uuid)) { userRooms.Remove(package.Uuid); } LogProvider.Log.Info(Logger, $"User {package.Uuid} left room {body.RoomId}."); }, () => LogProvider.Log.Info(Logger, $"User {package.Uuid} left room.")); var process = connectionsService.GetProcess(capturedPacket); var windowHandle = tableWindowProvider.GetTableWindowHandle(process); Task.Run(() => { Task.Delay(DelayToProcessHands * 2).Wait(); var args = new TableClosedEventArgs(windowHandle.ToInt32()); eventAggregator.GetEvent <TableClosedEvent>().Publish(args); }); detectedTableWindows.Remove(windowHandle); continue; } if (package.Cmd == PackageCommand.Cmd_SCEnterGameRoomRsp) { ParsePackage <SCEnterGameRoomRsp>(package, body => LogProvider.Log.Info(Logger, $"User {package.Uuid} entered room {body.RoomId}."), () => LogProvider.Log.Info(Logger, $"User {package.Uuid} entered room.")); continue; } if (package.Cmd == PackageCommand.Cmd_SCGameRoomStateChange) { var process = connectionsService.GetProcess(capturedPacket); var windowHandle = tableWindowProvider.GetTableWindowHandle(process); var newlyDetectedTable = false; if (!detectedTableWindows.Contains(windowHandle)) { detectedTableWindows.Add(windowHandle); newlyDetectedTable = true; } if (!HeroesKeys.TryGetValue(package.Uuid, out byte[] encryptKey))