diff --git a/SteamKit2/SteamKit2/Steam/Handlers/SteamApps/Callbacks.cs b/SteamKit2/SteamKit2/Steam/Handlers/SteamApps/Callbacks.cs index 190ab5e33..0cba92632 100644 --- a/SteamKit2/SteamKit2/Steam/Handlers/SteamApps/Callbacks.cs +++ b/SteamKit2/SteamKit2/Steam/Handlers/SteamApps/Callbacks.cs @@ -764,37 +764,6 @@ internal PurchaseResponseCallback( IPacketMsg packetMsg ) } } - /// - /// This callback is received when a CDN auth token is received - /// - public sealed class CDNAuthTokenCallback : CallbackMsg - { - /// - /// Result of the operation - /// - public EResult Result { get; set; } - /// - /// CDN auth token - /// - public string Token { get; set; } - /// - /// Token expiration date - /// - public DateTime Expiration { get; set; } - - internal CDNAuthTokenCallback( IPacketMsg packetMsg ) - { - var response = new ClientMsgProtobuf( packetMsg ); - var msg = response.Body; - - JobID = response.TargetJobID; - - Result = ( EResult )msg.eresult; - Token = msg.token; - Expiration = DateUtils.DateTimeFromUnixTime( msg.expiration_time ); - } - } - /// /// This callback is received when a beta password check has been completed /// diff --git a/SteamKit2/SteamKit2/Steam/Handlers/SteamApps/SteamApps.cs b/SteamKit2/SteamKit2/Steam/Handlers/SteamApps/SteamApps.cs index a3207895b..f5673befb 100644 --- a/SteamKit2/SteamKit2/Steam/Handlers/SteamApps/SteamApps.cs +++ b/SteamKit2/SteamKit2/Steam/Handlers/SteamApps/SteamApps.cs @@ -58,7 +58,6 @@ public PICSRequest( uint id = 0, ulong access_token = 0 ) EMsg.ClientPICSChangesSinceResponse => new PICSChangesCallback( packetMsg ), EMsg.ClientPICSProductInfoResponse => new PICSProductInfoCallback( packetMsg ), EMsg.ClientUpdateGuestPassesList => new GuestPassListCallback( packetMsg ), - EMsg.ClientGetCDNAuthTokenResponse => new CDNAuthTokenCallback( packetMsg ), EMsg.ClientCheckAppBetaPasswordResponse => new CheckAppBetaPasswordCallback( packetMsg ), _ => null, }; @@ -231,29 +230,6 @@ public AsyncJobMultiple PICSGetProductInfo( IEnumerable } - /// - /// Request product information for an app or package - /// Results are returned in a callback. - /// The returned can also be awaited to retrieve the callback result. - /// - /// App id requested. - /// Depot id requested. - /// CDN host name being requested. - /// The Job ID of the request. This can be used to find the appropriate . - public AsyncJob GetCDNAuthToken( uint app, uint depot, string host_name ) - { - var request = new ClientMsgProtobuf( EMsg.ClientGetCDNAuthToken ); - request.SourceJobID = Client.GetNextJobID(); - - request.Body.app_id = app; - request.Body.depot_id = depot; - request.Body.host_name = host_name; - - this.Client.Send( request ); - - return new AsyncJob( this.Client, request.SourceJobID ); - } - /// /// Request a free license for given appid, can be used for free on demand apps /// Results are returned in a callback. diff --git a/SteamKit2/SteamKit2/Steam/Handlers/SteamContent/SteamContent.cs b/SteamKit2/SteamKit2/Steam/Handlers/SteamContent/SteamContent.cs index b0447b04d..67af15a69 100644 --- a/SteamKit2/SteamKit2/Steam/Handlers/SteamContent/SteamContent.cs +++ b/SteamKit2/SteamKit2/Steam/Handlers/SteamContent/SteamContent.cs @@ -15,6 +15,33 @@ namespace SteamKit2 /// public sealed class SteamContent : ClientMsgHandler { + /// + /// This is received when a CDN auth token is received + /// + public sealed class CDNAuthToken + { + /// + /// Result of the operation + /// + public EResult Result { get; set; } + /// + /// CDN auth token + /// + public string Token { get; set; } + /// + /// Token expiration date + /// + public DateTime Expiration { get; set; } + + internal CDNAuthToken( SteamUnifiedMessages.ServiceMethodResponse message ) + { + var response = message.GetDeserializedResponse(); + Result = message.Result; + Token = response.token; + Expiration = DateUtils.DateTimeFromUnixTime( response.expiration_time ); + } + } + /// /// Load a list of servers from the Content Server Directory Service. /// This is an alternative to . @@ -91,6 +118,33 @@ public async Task GetManifestRequestCode( uint depotId, uint appId, ulong return response.manifest_request_code; } + /// + /// Request product information for an app or package + /// Results are returned in a . + /// The returned can also be awaited to retrieve the result. + /// + /// App id requested. + /// Depot id requested. + /// CDN host name being requested. + /// The Job ID of the request. This can be used to find the appropriate . + public async Task GetCDNAuthToken(uint app, uint depot, string host_name) + { + var request = new CContentServerDirectory_GetCDNAuthToken_Request + { + app_id = app, + depot_id = depot, + host_name = host_name, + }; + + // SendMessage is an AsyncJob, but we want to deserialize it + // can't really do HandleMsg because it requires parsing the service like its done in HandleServiceMethod + var unifiedMessages = Client.GetHandler()!; + var contentService = unifiedMessages.CreateService(); + var message = await contentService.SendMessage(api => api.GetCDNAuthToken(request)); + + return new CDNAuthToken( message ); + } + /// /// Handles a client message. This should not be called directly. ///