更改文件架构
This commit is contained in:
parent
93292b1a59
commit
ed84166723
File diff suppressed because one or more lines are too long
|
@ -14,7 +14,7 @@ namespace BITKit
|
|||
/// 基于GDNet的网络服务
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class GDNetService:INetProvider,INetClient
|
||||
public class GDNetService:MonoBehaviour, INetProvider,INetClient
|
||||
{
|
||||
//服务器地址与端口号
|
||||
[Header(Constant.Header.Settings)]
|
||||
|
@ -22,8 +22,8 @@ namespace BITKit
|
|||
[SerializeField] private ushort port;
|
||||
[Header(Constant.Header.Components)]
|
||||
//绑定GDNet的ClientManager
|
||||
[SerializeField]
|
||||
private ClientManager clientManager;
|
||||
[SerializeField,SerializeReference,SubclassSelector]
|
||||
private INetClientProvider clientProvider;
|
||||
//内部事件系统
|
||||
private readonly GenericEvent eventSystem = new();
|
||||
//内部变量
|
||||
|
@ -31,7 +31,7 @@ namespace BITKit
|
|||
//已保存的Rpc对象
|
||||
private readonly List<object> rpcHandles = new();
|
||||
//GDNet的网络客户端
|
||||
private ClientBase client => clientManager.client;
|
||||
private ClientBase client;
|
||||
/// <summary>
|
||||
/// 是否已连接到服务端
|
||||
/// </summary>
|
||||
|
@ -88,7 +88,7 @@ namespace BITKit
|
|||
|
||||
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)
|
||||
|
@ -121,16 +121,19 @@ namespace BITKit
|
|||
|
||||
public void Disconnect()
|
||||
{
|
||||
if (IsConnected)
|
||||
{
|
||||
client.Close();
|
||||
OnDisconnected.Invoke();
|
||||
}
|
||||
if (!IsConnected) return;
|
||||
client.Close();
|
||||
OnDisconnected?.Invoke();
|
||||
}
|
||||
private void OnReceiveCommand(object command)
|
||||
{
|
||||
eventSystem.Invoke($"{command.GetType().FullName}.{Constant.System.Internal}",command);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
client = clientProvider.GetClient();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7e6a775310ef1f845ab84594ee93ed03
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7eb9c29a8aafb064dbf8d0fef7db9faf
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 98295d9f0ccb8744dada94e501ac87b3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 44f1c4dc774dae94580dab0b0d30b8d1
|
||||
guid: c91464c2b86606640bd9080b4f792bb5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
|
@ -31,7 +31,7 @@ namespace BITKit
|
|||
public const string Services = nameof(Services);
|
||||
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 AllowTouchSupport = new();
|
||||
public static GameObject GameObject;
|
||||
|
@ -40,7 +40,7 @@ namespace BITKit
|
|||
#if UNITY_EDITOR
|
||||
if (IsPlaying is false)
|
||||
{
|
||||
throw new System.Exception("Editor Is Not Playing");
|
||||
throw new AppIsNotPlayingException();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ namespace BITKit
|
|||
#endif
|
||||
}
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
static async void Reload()
|
||||
private static async void Reload()
|
||||
{
|
||||
IsPlaying = true;
|
||||
BIT4Log.OnLog += Debug.Log;
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"reference": "GUID:14fe60d984bf9f84eac55c6ea033a8f4"
|
||||
}
|
|
@ -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
Loading…
Reference in New Issue