修改方法
This commit is contained in:
parent
a0364969c1
commit
c48d7fd34d
|
|
@ -27,7 +27,7 @@ namespace CloudGaming.Code.Contract
|
||||||
/// <param name="requestParameter"></param>
|
/// <param name="requestParameter"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Post("/jyapi/getToken")]
|
[Post("/jyapi/getToken")]
|
||||||
Task<JYResponseCode<GetTokenModel>> GetToken([Body(BodySerializationMethod.UrlEncoded)] JYRequestParameter requestParameter);
|
Task<JYApiResponse<GetTokenModel>> GetToken([Body(BodySerializationMethod.UrlEncoded)] JYRequestParameter requestParameter);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启动游戏
|
/// 启动游戏
|
||||||
|
|
@ -35,7 +35,7 @@ namespace CloudGaming.Code.Contract
|
||||||
/// <param name="playGameSettings"></param>
|
/// <param name="playGameSettings"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Post("/jyapi/playGame")]
|
[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>
|
/// <summary>
|
||||||
///排队查询
|
///排队查询
|
||||||
|
|
@ -43,7 +43,7 @@ namespace CloudGaming.Code.Contract
|
||||||
/// <param name="playGameQueue"></param>
|
/// <param name="playGameQueue"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Post("/jyapi/playQueue")]
|
[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>
|
/// <summary>
|
||||||
/// 取消排队
|
/// 取消排队
|
||||||
|
|
@ -51,7 +51,7 @@ namespace CloudGaming.Code.Contract
|
||||||
/// <param name="playGameQueue"></param>
|
/// <param name="playGameQueue"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Post("/jyapi/cancelQueue")]
|
[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>
|
/// <summary>
|
||||||
/// 切换视频等级
|
/// 切换视频等级
|
||||||
|
|
@ -59,7 +59,7 @@ namespace CloudGaming.Code.Contract
|
||||||
/// <param name="playGameQueue"></param>
|
/// <param name="playGameQueue"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Post("/jyapi/displayGrade")]
|
[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>
|
/// <summary>
|
||||||
/// 切换视频等级
|
/// 切换视频等级
|
||||||
|
|
@ -67,7 +67,7 @@ namespace CloudGaming.Code.Contract
|
||||||
/// <param name="playGameQueue"></param>
|
/// <param name="playGameQueue"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Post("/jyapi/reconPlayGame")]
|
[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>
|
/// <summary>
|
||||||
/// 停止游戏
|
/// 停止游戏
|
||||||
|
|
@ -75,14 +75,14 @@ namespace CloudGaming.Code.Contract
|
||||||
/// <param name="playGameQueue"></param>
|
/// <param name="playGameQueue"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Post("/jyapi/stopGame")]
|
[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>
|
||||||
/// 获取会话列表
|
/// 获取会话列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Post("/jyapi/getSessionList")]
|
[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>
|
/// <returns></returns>
|
||||||
public async Task<string> GetTokenAsync(RequestBaseModel requestBaseModel)
|
public async Task<string> GetTokenAsync(RequestBaseModel requestBaseModel)
|
||||||
{
|
{
|
||||||
if (_UserId == 0)
|
//if (_UserId == 0)
|
||||||
{
|
//{
|
||||||
throw MessageBox.ErrorShow("请先登录");
|
// throw MessageBox.ErrorShow("请先登录");
|
||||||
}
|
//}
|
||||||
if (string.IsNullOrEmpty(requestBaseModel.Sn))
|
if (string.IsNullOrEmpty(requestBaseModel.Sn))
|
||||||
{
|
{
|
||||||
throw MessageBox.ErrorShow("设备号不能为空");
|
throw MessageBox.ErrorShow("设备号不能为空");
|
||||||
|
|
@ -105,7 +105,6 @@ namespace CloudGaming.Code.Game
|
||||||
playGameSettings.ModelName = modelName;
|
playGameSettings.ModelName = modelName;
|
||||||
playGameSettings.StartResolution = "1080P";
|
playGameSettings.StartResolution = "1080P";
|
||||||
var data = await JYApi.PlayGame(playGameSettings);
|
var data = await JYApi.PlayGame(playGameSettings);
|
||||||
//var jobj = JsonConvert.DeserializeObject<JObject>(data);
|
|
||||||
T_User_GameList t_User_GameList = new T_User_GameList()
|
T_User_GameList t_User_GameList = new T_User_GameList()
|
||||||
{
|
{
|
||||||
Channel = this.AppRequestInfo.Channel,
|
Channel = this.AppRequestInfo.Channel,
|
||||||
|
|
@ -117,7 +116,7 @@ namespace CloudGaming.Code.Game
|
||||||
UpdateTime = DateTime.Now,
|
UpdateTime = DateTime.Now,
|
||||||
UserId = _UserId,
|
UserId = _UserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (data.IsLineUp)
|
if (data.IsLineUp)
|
||||||
{
|
{
|
||||||
t_User_GameList.Status = (int)PlayGameStatus.排队中;
|
t_User_GameList.Status = (int)PlayGameStatus.排队中;
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,7 @@
|
||||||
using CloudGaming.Code.AppExtend;
|
using Newtonsoft.Json;
|
||||||
using CloudGaming.Code.AppExtend.ConfigModel;
|
using Newtonsoft.Json.Linq;
|
||||||
using CloudGaming.DtoModel.PlayGame;
|
|
||||||
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CloudGaming.Code.JY;
|
namespace CloudGaming.Code.JY;
|
||||||
|
|
||||||
|
|
@ -66,10 +59,23 @@ public class JYApiHandler : DelegatingHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//var x = await base.SendAsync(request, cancellationToken);
|
var settings = new JsonSerializerSettings
|
||||||
//var json = await x.Content.ReadAsStringAsync();
|
{
|
||||||
//调用下一个处理器
|
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||||
return await base.SendAsync(request, cancellationToken); ;
|
};
|
||||||
|
//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)
|
private SortedDictionary<string, object> ParseFormData(string formData)
|
||||||
{
|
{
|
||||||
|
|
@ -92,7 +98,7 @@ public class JYApiHandler : DelegatingHandler
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dic"></param>
|
/// <param name="dic"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private static string dic2PostData(SortedDictionary<string, object> dic)
|
private string dic2PostData(SortedDictionary<string, object> dic)
|
||||||
{
|
{
|
||||||
StringBuilder postData = new StringBuilder();
|
StringBuilder postData = new StringBuilder();
|
||||||
foreach (var item in dic)
|
foreach (var item in dic)
|
||||||
|
|
@ -115,7 +121,7 @@ public class JYApiHandler : DelegatingHandler
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dicParams"></param>
|
/// <param name="dicParams"></param>
|
||||||
/// <returns></returns>
|
/// <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();
|
StringBuilder str = new StringBuilder();
|
||||||
foreach (var item in dicParams)
|
foreach (var item in dicParams)
|
||||||
|
|
@ -132,4 +138,17 @@ public class JYApiHandler : DelegatingHandler
|
||||||
str.AppendFormat("&key={0}", key);
|
str.AppendFormat("&key={0}", key);
|
||||||
return MD5Encryption.ComputeMD5Hash(str.ToString()).ToUpper();
|
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