大调整
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
namespace Assets.Scripts.Entity
|
||||
namespace NBF
|
||||
{
|
||||
public class AuthenticationSelectComponent : Fantasy.Entitas.Entity
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Assets.Scripts.Entity
|
||||
namespace NBF
|
||||
{
|
||||
public sealed class Payload
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ using Fantasy.Network;
|
||||
using Fantasy.Network.Interface;
|
||||
using Log = NBC.Log;
|
||||
|
||||
namespace Assets.Scripts.Hotfix
|
||||
namespace NBF
|
||||
{
|
||||
public sealed class G2C_RepeatLoginHandler : Message<G2C_RepeatLogin>
|
||||
{
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Assets.Scripts.Entity;
|
||||
using Fantasy.Helper;
|
||||
|
||||
namespace Assets.Scripts.Hotfix
|
||||
namespace NBF
|
||||
{
|
||||
public static class AuthenticationSelectComponentSystem
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using Assets.Scripts.Entity;
|
||||
using Fantasy.Helper;
|
||||
using NBC;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Assets.Scripts.Hotfix
|
||||
namespace NBF
|
||||
{
|
||||
public static class JWTParseComponentSystem
|
||||
{
|
||||
@@ -11,7 +11,7 @@ namespace Assets.Scripts.Hotfix
|
||||
public static bool Parse(this JWTParseComponent self, string toKen, out Payload payloadData)
|
||||
{
|
||||
payloadData = null;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
// JWT通常是由三个部分组成的,Header,Payload,Signature。
|
||||
@@ -22,6 +22,7 @@ namespace Assets.Scripts.Hotfix
|
||||
Log.Error("Invalid JWT token");
|
||||
return false;
|
||||
}
|
||||
|
||||
// JWT的Payload不是标准的Base64格式,因为咱们C#的Convert要求是一个标准的Base64格式。
|
||||
// JWT的Payload是Base64URL格式,它里面的"-"替代成了"+","_"替代成了"/",需要把这些给还原成Base64格式
|
||||
var basePayload = tokens[1].Replace('-', '+').Replace('_', '/');
|
||||
@@ -41,19 +42,21 @@ namespace Assets.Scripts.Hotfix
|
||||
// }
|
||||
case 2:
|
||||
{
|
||||
basePayload +="==";
|
||||
basePayload += "==";
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
basePayload +="=";
|
||||
basePayload += "=";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 将修复后的字符串解码为数组
|
||||
var basePayloadBytes = Convert.FromBase64String(basePayload);
|
||||
var payload = System.Text.Encoding.UTF8.GetString(basePayloadBytes);
|
||||
payloadData = JsonHelper.Deserialize<Payload>(payload);
|
||||
payloadData =
|
||||
JsonConvert.DeserializeObject<Payload>(payload); //JsonHelper.Deserialize<Payload>(payload);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
using System;
|
||||
using Fantasy;
|
||||
using Fantasy.Network;
|
||||
using NBC;
|
||||
|
||||
namespace Assets.Scripts.Hotfix
|
||||
{
|
||||
public static class SessionHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建一个网络会话
|
||||
/// </summary>
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="address">远程服务器地址</param>
|
||||
/// <param name="onConnectComplete">当连接成功执行的委托,可为空</param>
|
||||
/// <param name="onConnectFail">当连接超时或失败执行的委托,可为空</param>
|
||||
/// <param name="onConnectDisconnect">当连接断开执行的委托,可为空</param>
|
||||
/// <returns></returns>
|
||||
public static Session CreateSession(Scene scene, string address, Action onConnectComplete, Action onConnectFail,
|
||||
Action onConnectDisconnect)
|
||||
{
|
||||
return scene.Connect(
|
||||
address,
|
||||
NetworkProtocolType.KCP,
|
||||
onConnectComplete,
|
||||
onConnectFail,
|
||||
onConnectDisconnect,
|
||||
false, 5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
// using System;
|
||||
// using Fantasy;
|
||||
// using Fantasy.Network;
|
||||
// using NBC;
|
||||
//
|
||||
// namespace NBF
|
||||
// {
|
||||
// public static class SessionHelper
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// 创建一个网络会话
|
||||
// /// </summary>
|
||||
// /// <param name="scene"></param>
|
||||
// /// <param name="address">远程服务器地址</param>
|
||||
// /// <param name="onConnectComplete">当连接成功执行的委托,可为空</param>
|
||||
// /// <param name="onConnectFail">当连接超时或失败执行的委托,可为空</param>
|
||||
// /// <param name="onConnectDisconnect">当连接断开执行的委托,可为空</param>
|
||||
// /// <returns></returns>
|
||||
// public static Session CreateSession(Scene scene, string address, Action onConnectComplete, Action onConnectFail,
|
||||
// Action onConnectDisconnect)
|
||||
// {
|
||||
// return scene.Connect(
|
||||
// address,
|
||||
// NetworkProtocolType.KCP,
|
||||
// onConnectComplete,
|
||||
// onConnectFail,
|
||||
// onConnectDisconnect,
|
||||
// false, 5000);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -1,6 +1,4 @@
|
||||
using Assets.Scripts.Entity;
|
||||
using Assets.Scripts.Hotfix;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network;
|
||||
using Fantasy.Network.Interface;
|
||||
using NBC;
|
||||
|
||||
Reference in New Issue
Block a user