修改方法
This commit is contained in:
parent
a0364969c1
commit
c48d7fd34d
|
|
@ -27,7 +27,7 @@ namespace CloudGaming.Code.Contract
|
|||
/// <param name="requestParameter"></param>
|
||||
/// <returns></returns>
|
||||
[Post("/jyapi/getToken")]
|
||||
Task<JYResponseCode<GetTokenModel>> GetToken([Body(BodySerializationMethod.UrlEncoded)] JYRequestParameter requestParameter);
|
||||
Task<JYApiResponse<GetTokenModel>> GetToken([Body(BodySerializationMethod.UrlEncoded)] JYRequestParameter requestParameter);
|
||||
|
||||
/// <summary>
|
||||
/// 启动游戏
|
||||
|
|
@ -35,7 +35,7 @@ namespace CloudGaming.Code.Contract
|
|||
/// <param name="playGameSettings"></param>
|
||||
/// <returns></returns>
|
||||
[Post("/jyapi/playGame")]
|
||||
Task<JYResponseCode<Dictionary<string, object>>> PlayGame([Body(BodySerializationMethod.UrlEncoded)] PlayGameSettings playGameSettings);
|
||||
Task<JYApiResponse<Dictionary<string, object>>> PlayGame([Body(BodySerializationMethod.UrlEncoded)] PlayGameSettings playGameSettings);
|
||||
|
||||
/// <summary>
|
||||
///排队查询
|
||||
|
|
@ -43,7 +43,7 @@ namespace CloudGaming.Code.Contract
|
|||
/// <param name="playGameQueue"></param>
|
||||
/// <returns></returns>
|
||||
[Post("/jyapi/playQueue")]
|
||||
Task<JYResponseCode<Dictionary<string, object>>> PlayGame([Body(BodySerializationMethod.UrlEncoded)] PlayGameQueue playGameQueue);
|
||||
Task<JYApiResponse<Dictionary<string, object>>> PlayGame([Body(BodySerializationMethod.UrlEncoded)] PlayGameQueue playGameQueue);
|
||||
|
||||
/// <summary>
|
||||
/// 取消排队
|
||||
|
|
@ -51,7 +51,7 @@ namespace CloudGaming.Code.Contract
|
|||
/// <param name="playGameQueue"></param>
|
||||
/// <returns></returns>
|
||||
[Post("/jyapi/cancelQueue")]
|
||||
Task<JYResponseCode<Dictionary<string, object>>> CancelQueue([Body(BodySerializationMethod.UrlEncoded)] PlayGameQueue playGameQueue);
|
||||
Task<JYApiResponse<Dictionary<string, object>>> CancelQueue([Body(BodySerializationMethod.UrlEncoded)] PlayGameQueue playGameQueue);
|
||||
|
||||
/// <summary>
|
||||
/// 切换视频等级
|
||||
|
|
@ -59,7 +59,7 @@ namespace CloudGaming.Code.Contract
|
|||
/// <param name="playGameQueue"></param>
|
||||
/// <returns></returns>
|
||||
[Post("/jyapi/displayGrade")]
|
||||
Task<JYResponseCode<Dictionary<string, object>>> DisplayGrade([Body(BodySerializationMethod.UrlEncoded)] DisplayGradeSettings playGameQueue);
|
||||
Task<JYApiResponse<Dictionary<string, object>>> DisplayGrade([Body(BodySerializationMethod.UrlEncoded)] DisplayGradeSettings playGameQueue);
|
||||
|
||||
/// <summary>
|
||||
/// 切换视频等级
|
||||
|
|
@ -67,7 +67,7 @@ namespace CloudGaming.Code.Contract
|
|||
/// <param name="playGameQueue"></param>
|
||||
/// <returns></returns>
|
||||
[Post("/jyapi/reconPlayGame")]
|
||||
Task<JYResponseCode<Dictionary<string, object>>> ReconPlayGame([Body(BodySerializationMethod.UrlEncoded)] DisplayGradeSettings playGameQueue);
|
||||
Task<JYApiResponse<Dictionary<string, object>>> ReconPlayGame([Body(BodySerializationMethod.UrlEncoded)] DisplayGradeSettings playGameQueue);
|
||||
|
||||
/// <summary>
|
||||
/// 停止游戏
|
||||
|
|
@ -75,14 +75,14 @@ namespace CloudGaming.Code.Contract
|
|||
/// <param name="playGameQueue"></param>
|
||||
/// <returns></returns>
|
||||
[Post("/jyapi/stopGame")]
|
||||
Task<JYResponseCode<Dictionary<string, object>>> StopGame([Body(BodySerializationMethod.UrlEncoded)] PlayGameCommonSetting playGameQueue);
|
||||
Task<JYApiResponse<Dictionary<string, object>>> StopGame([Body(BodySerializationMethod.UrlEncoded)] PlayGameCommonSetting playGameQueue);
|
||||
|
||||
/// <summary>
|
||||
/// 获取会话列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Post("/jyapi/getSessionList")]
|
||||
Task<JYResponseCode<Dictionary<string, object>>> GetSessionList();
|
||||
Task<JYApiResponse<Dictionary<string, object>>> GetSessionList();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,10 +37,10 @@ namespace CloudGaming.Code.Game
|
|||
/// <returns></returns>
|
||||
public async Task<string> GetTokenAsync(RequestBaseModel requestBaseModel)
|
||||
{
|
||||
if (_UserId == 0)
|
||||
{
|
||||
throw MessageBox.ErrorShow("请先登录");
|
||||
}
|
||||
//if (_UserId == 0)
|
||||
//{
|
||||
// throw MessageBox.ErrorShow("请先登录");
|
||||
//}
|
||||
if (string.IsNullOrEmpty(requestBaseModel.Sn))
|
||||
{
|
||||
throw MessageBox.ErrorShow("设备号不能为空");
|
||||
|
|
@ -105,7 +105,6 @@ namespace CloudGaming.Code.Game
|
|||
playGameSettings.ModelName = modelName;
|
||||
playGameSettings.StartResolution = "1080P";
|
||||
var data = await JYApi.PlayGame(playGameSettings);
|
||||
//var jobj = JsonConvert.DeserializeObject<JObject>(data);
|
||||
T_User_GameList t_User_GameList = new T_User_GameList()
|
||||
{
|
||||
Channel = this.AppRequestInfo.Channel,
|
||||
|
|
|
|||
|
|
@ -1,14 +1,7 @@
|
|||
using CloudGaming.Code.AppExtend;
|
||||
using CloudGaming.Code.AppExtend.ConfigModel;
|
||||
using CloudGaming.DtoModel.PlayGame;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CloudGaming.Code.JY;
|
||||
|
||||
|
|
@ -66,10 +59,23 @@ public class JYApiHandler : DelegatingHandler
|
|||
}
|
||||
|
||||
}
|
||||
//var x = await base.SendAsync(request, cancellationToken);
|
||||
//var json = await x.Content.ReadAsStringAsync();
|
||||
//调用下一个处理器
|
||||
return await base.SendAsync(request, cancellationToken); ;
|
||||
var settings = new JsonSerializerSettings
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||
};
|
||||
//var re = JsonConvert.SerializeObject(request, settings);
|
||||
var response = await base.SendAsync(request, cancellationToken);
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var contentString = await response.Content.ReadAsStringAsync();
|
||||
var jobj = JsonConvert.DeserializeObject<JObject>(contentString);
|
||||
jobj["RequestStr"] = await request.ToJsonAsync();
|
||||
jobj["ResponseStr"] = SerializeHttpResponseMessage(response, contentString);
|
||||
var json = JsonConvert.SerializeObject(jobj);
|
||||
var newContent = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
response.Content = newContent;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
private SortedDictionary<string, object> ParseFormData(string formData)
|
||||
{
|
||||
|
|
@ -92,7 +98,7 @@ public class JYApiHandler : DelegatingHandler
|
|||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
private static string dic2PostData(SortedDictionary<string, object> dic)
|
||||
private string dic2PostData(SortedDictionary<string, object> dic)
|
||||
{
|
||||
StringBuilder postData = new StringBuilder();
|
||||
foreach (var item in dic)
|
||||
|
|
@ -115,7 +121,7 @@ public class JYApiHandler : DelegatingHandler
|
|||
/// </summary>
|
||||
/// <param name="dicParams"></param>
|
||||
/// <returns></returns>
|
||||
public static string signEncode(SortedDictionary<string, object> dicParams, string key)
|
||||
public string signEncode(SortedDictionary<string, object> dicParams, string key)
|
||||
{
|
||||
StringBuilder str = new StringBuilder();
|
||||
foreach (var item in dicParams)
|
||||
|
|
@ -132,4 +138,17 @@ public class JYApiHandler : DelegatingHandler
|
|||
str.AppendFormat("&key={0}", key);
|
||||
return MD5Encryption.ComputeMD5Hash(str.ToString()).ToUpper();
|
||||
}
|
||||
|
||||
public string SerializeHttpResponseMessage(HttpResponseMessage response, string content)
|
||||
{
|
||||
var responseInfo = new
|
||||
{
|
||||
StatusCode = response.StatusCode,
|
||||
ReasonPhrase = response.ReasonPhrase,
|
||||
Headers = response.Headers,
|
||||
Content = content,
|
||||
};
|
||||
|
||||
return JsonConvert.SerializeObject(responseInfo, Formatting.None);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
using HuanMeng.DotNetCore.Base;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CloudGaming.DtoModel.JY
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class JYApiResponse<T> : JYResponseCode<T> where T : class, new()
|
||||
{
|
||||
public string RequestStr { get; set; } // 请求信息
|
||||
public string ResponseStr { get; set; } // 响应信息
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
using Newtonsoft.Json;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HuanMeng.DotNetCore.Utility;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class HttpRequestMessageExtensions
|
||||
{
|
||||
public static async Task<string> ToJsonAsync(this HttpRequestMessage request)
|
||||
{
|
||||
var requestInfo = new
|
||||
{
|
||||
Method = request.Method.Method,
|
||||
Url = request.RequestUri?.ToString(),
|
||||
Headers = request.Headers,
|
||||
Content = request.Content != null ? await request.Content.ReadAsStringAsync() : null
|
||||
};
|
||||
|
||||
return JsonConvert.SerializeObject(requestInfo, Formatting.None);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
using Newtonsoft.Json;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HuanMeng.DotNetCore.Utility;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class HttpResponseMessageExtensions
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="response"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<string> ToJsonAsync(this HttpResponseMessage response)
|
||||
{
|
||||
var responseInfo = new
|
||||
{
|
||||
StatusCode = response.StatusCode,
|
||||
ReasonPhrase = response.ReasonPhrase,
|
||||
Headers = response.Headers,
|
||||
Content = response.Content != null ? await response.Content.ReadAsStringAsync() : null,
|
||||
RequestMessage = response.RequestMessage != null
|
||||
? new
|
||||
{
|
||||
Method = response.RequestMessage.Method.Method,
|
||||
Url = response.RequestMessage.RequestUri.ToString()
|
||||
}
|
||||
: null
|
||||
};
|
||||
|
||||
return JsonConvert.SerializeObject(responseInfo, Formatting.Indented);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user