public override void HandleMsg(IPacketMsg packetMsg) { if (packetMsg == null) { ArchiLogger.LogNullError(nameof(packetMsg)); return; } if (Client == null) { ArchiLogger.LogNullError(nameof(Client)); return; } LastPacketReceived = DateTime.UtcNow; switch (packetMsg.MsgType) { case EMsg.ClientCommentNotifications: ClientMsgProtobuf <CMsgClientCommentNotifications> commentNotifications = new ClientMsgProtobuf <CMsgClientCommentNotifications>(packetMsg); Client.PostCallback(new UserNotificationsCallback(packetMsg.TargetJobID, commentNotifications.Body)); break; case EMsg.ClientItemAnnouncements: ClientMsgProtobuf <CMsgClientItemAnnouncements> itemAnnouncements = new ClientMsgProtobuf <CMsgClientItemAnnouncements>(packetMsg); Client.PostCallback(new UserNotificationsCallback(packetMsg.TargetJobID, itemAnnouncements.Body)); break; case EMsg.ClientPlayingSessionState: ClientMsgProtobuf <CMsgClientPlayingSessionState> playingSessionState = new ClientMsgProtobuf <CMsgClientPlayingSessionState>(packetMsg); Client.PostCallback(new PlayingSessionStateCallback(packetMsg.TargetJobID, playingSessionState.Body)); break; case EMsg.ClientPurchaseResponse: ClientMsgProtobuf <CMsgClientPurchaseResponse> purchaseResponse = new ClientMsgProtobuf <CMsgClientPurchaseResponse>(packetMsg); Client.PostCallback(new PurchaseResponseCallback(packetMsg.TargetJobID, purchaseResponse.Body)); break; case EMsg.ClientRedeemGuestPassResponse: ClientMsgProtobuf <CMsgClientRedeemGuestPassResponse> redeemGuestPassResponse = new ClientMsgProtobuf <CMsgClientRedeemGuestPassResponse>(packetMsg); Client.PostCallback(new RedeemGuestPassResponseCallback(packetMsg.TargetJobID, redeemGuestPassResponse.Body)); break; case EMsg.ClientSharedLibraryLockStatus: ClientMsgProtobuf <CMsgClientSharedLibraryLockStatus> sharedLibraryLockStatus = new ClientMsgProtobuf <CMsgClientSharedLibraryLockStatus>(packetMsg); Client.PostCallback(new SharedLibraryLockStatusCallback(packetMsg.TargetJobID, sharedLibraryLockStatus.Body)); break; case EMsg.ClientUserNotifications: ClientMsgProtobuf <CMsgClientUserNotifications> userNotifications = new ClientMsgProtobuf <CMsgClientUserNotifications>(packetMsg); Client.PostCallback(new UserNotificationsCallback(packetMsg.TargetJobID, userNotifications.Body)); break; case EMsg.ClientVanityURLChangedNotification: ClientMsgProtobuf <CMsgClientVanityURLChangedNotification> vanityURLChangedNotification = new ClientMsgProtobuf <CMsgClientVanityURLChangedNotification>(packetMsg); Client.PostCallback(new VanityURLChangedCallback(packetMsg.TargetJobID, vanityURLChangedNotification.Body)); break; } }
internal async Task PlayGames(IEnumerable <uint> gameIDs, string gameName = null) { if (gameIDs == null) { ArchiLogger.LogNullError(nameof(gameIDs)); return; } if (Client == null) { ArchiLogger.LogNullError(nameof(Client)); return; } if (!Client.IsConnected) { return; } ClientMsgProtobuf <CMsgClientGamesPlayed> request = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayedWithDataBlob) { Body = { client_os_type = (uint)Bot.OSType } }; byte maxGamesCount = MaxGamesPlayedConcurrently; if (!string.IsNullOrEmpty(gameName)) { // If we have custom name to display, we must workaround the Steam network broken behaviour and send request on clean non-playing session // This ensures that custom name will in fact display properly Client.Send(request); await Task.Delay(Bot.CallbackSleep).ConfigureAwait(false); request.Body.games_played.Add( new CMsgClientGamesPlayed.GamePlayed { game_extra_info = gameName, game_id = new GameID { AppType = GameID.GameType.Shortcut, ModID = uint.MaxValue } } ); // Max games count is affected by valid AppIDs only, therefore gameName alone doesn't need exclusive slot maxGamesCount++; } foreach (uint gameID in gameIDs.Where(gameID => gameID != 0)) { request.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed { game_id = new GameID(gameID) }); if (request.Body.games_played.Count >= maxGamesCount) { break; } } Client.Send(request); }