更改文件架构

This commit is contained in:
CortexCore 2023-06-07 18:38:07 +08:00
parent 93292b1a59
commit ed84166723
720 changed files with 297 additions and 65 deletions

File diff suppressed because one or more lines are too long

View File

@ -14,7 +14,7 @@ namespace BITKit
/// 基于GDNet的网络服务 /// 基于GDNet的网络服务
/// </summary> /// </summary>
[Serializable] [Serializable]
public class GDNetService:INetProvider,INetClient public class GDNetService:MonoBehaviour, INetProvider,INetClient
{ {
//服务器地址与端口号 //服务器地址与端口号
[Header(Constant.Header.Settings)] [Header(Constant.Header.Settings)]
@ -22,8 +22,8 @@ namespace BITKit
[SerializeField] private ushort port; [SerializeField] private ushort port;
[Header(Constant.Header.Components)] [Header(Constant.Header.Components)]
//绑定GDNet的ClientManager //绑定GDNet的ClientManager
[SerializeField] [SerializeField,SerializeReference,SubclassSelector]
private ClientManager clientManager; private INetClientProvider clientProvider;
//内部事件系统 //内部事件系统
private readonly GenericEvent eventSystem = new(); private readonly GenericEvent eventSystem = new();
//内部变量 //内部变量
@ -31,7 +31,7 @@ namespace BITKit
//已保存的Rpc对象 //已保存的Rpc对象
private readonly List<object> rpcHandles = new(); private readonly List<object> rpcHandles = new();
//GDNet的网络客户端 //GDNet的网络客户端
private ClientBase client => clientManager.client; private ClientBase client;
/// <summary> /// <summary>
/// 是否已连接到服务端 /// 是否已连接到服务端
/// </summary> /// </summary>
@ -88,7 +88,7 @@ namespace BITKit
public void SendRT(string rpcName, params object[] pars) public void SendRT(string rpcName, params object[] pars)
{ {
clientManager.SendRT(rpcName,pars); client.SendRT(rpcName,pars);
} }
public void SendTargetRT(int id, string rpcName, params object[] pars) public void SendTargetRT(int id, string rpcName, params object[] pars)
@ -121,16 +121,19 @@ namespace BITKit
public void Disconnect() public void Disconnect()
{ {
if (IsConnected) if (!IsConnected) return;
{
client.Close(); client.Close();
OnDisconnected.Invoke(); OnDisconnected?.Invoke();
}
} }
private void OnReceiveCommand(object command) private void OnReceiveCommand(object command)
{ {
eventSystem.Invoke($"{command.GetType().FullName}.{Constant.System.Internal}",command); eventSystem.Invoke($"{command.GetType().FullName}.{Constant.System.Internal}",command);
} }
private void Start()
{
client = clientProvider.GetClient();
}
} }
} }

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7e6a775310ef1f845ab84594ee93ed03
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,18 @@
{
"name": "BITKit.WXPusher",
"rootNamespace": "",
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
"GUID:be17a8778dbfe454890ed8279279e153"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7eb9c29a8aafb064dbf8d0fef7db9faf
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using BITKit.HttpNet;
using UnityEngine;
namespace BITKit
{
public class WeChatMessagePusher : MonoBehaviour
{
private const string url = "https://wxpusher.zjiecode.com/api/send/message";
[SerializeField, SerializeReference, SubclassSelector]
private Reference appName;
[SerializeField, SerializeReference, SubclassSelector]
private Reference appToken;
[SerializeField, SerializeReference, SubclassSelector]
private Reference[] uids;
[SerializeField, SerializeReference, SubclassSelector]
private IWebProvider webProvider;
public async void PostMessage(object message)
{
var content = message is string ? message.ToString() : JsonHelper.Get(message);
WeChatMessage wxMessage = new()
{
appToken = appToken,
summary = appName,
content = content
};
if (uids.Length > 0)
{
wxMessage.uids = uids.Select(x => x.Get()).ToArray();
}
await webProvider.PostAsync(url, wxMessage);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 98295d9f0ccb8744dada94e501ac87b3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 44f1c4dc774dae94580dab0b0d30b8d1 guid: c91464c2b86606640bd9080b4f792bb5
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

View File

@ -31,7 +31,7 @@ namespace BITKit
public const string Services = nameof(Services); public const string Services = nameof(Services);
public const string Prefabs = nameof(Prefabs); public const string Prefabs = nameof(Prefabs);
} }
public static bool IsPlaying { get; private set; } private static bool IsPlaying { get; set; }
public static ValidHandle AllowCursor = new(); public static ValidHandle AllowCursor = new();
public static ValidHandle AllowTouchSupport = new(); public static ValidHandle AllowTouchSupport = new();
public static GameObject GameObject; public static GameObject GameObject;
@ -40,7 +40,7 @@ namespace BITKit
#if UNITY_EDITOR #if UNITY_EDITOR
if (IsPlaying is false) if (IsPlaying is false)
{ {
throw new System.Exception("Editor Is Not Playing"); throw new AppIsNotPlayingException();
} }
#endif #endif
} }
@ -55,7 +55,7 @@ namespace BITKit
#endif #endif
} }
[RuntimeInitializeOnLoadMethod] [RuntimeInitializeOnLoadMethod]
static async void Reload() private static async void Reload()
{ {
IsPlaying = true; IsPlaying = true;
BIT4Log.OnLog += Debug.Log; BIT4Log.OnLog += Debug.Log;

View File

@ -0,0 +1,3 @@
{
"reference": "GUID:14fe60d984bf9f84eac55c6ea033a8f4"
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e6698f38bbe091640b9fa934fda7abc3
AssemblyDefinitionReferenceImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More