Removed Many Things
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BITKit.HttpNet
|
||||
{
|
||||
[System.Serializable]
|
||||
public sealed class HttpClient : WebProvider
|
||||
{
|
||||
System.Net.Http.HttpClient client = new();
|
||||
public override async UniTask<string> GetAsync(string url, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var response = await client.GetAsync(url, cancellationToken);
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
public override async UniTask<string> PostAsync<T>(string url, T value, CancellationToken cancellationToken = default)
|
||||
{
|
||||
HttpContent content = value switch
|
||||
{
|
||||
string _string => new StringContent(_string,Encoding.Unicode,"application/json"),
|
||||
_ => new StringContent(JsonConvert.SerializeObject(value),Encoding.Unicode,"application/json")
|
||||
};
|
||||
using var response = await client.PostAsync(url, content, cancellationToken);
|
||||
if (response.StatusCode is HttpStatusCode.OK)
|
||||
{
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
BIT4Log.Log<HttpClient>(response.StatusCode);
|
||||
return response.StatusCode.ToString();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58537b58f476c684eb389c901f34d85b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 128d422e2a086e44f9110995b6eafd4b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,16 +0,0 @@
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace BITKit.HttpNet
|
||||
{
|
||||
public interface IWebProvider
|
||||
{
|
||||
UniTask<string> GetAsync(string url, CancellationToken cancellationToken = default);
|
||||
async UniTask<T> GetAsync<T>(string url, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var json = await GetAsync(url, cancellationToken);
|
||||
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(json);
|
||||
}
|
||||
UniTask<string> PostAsync<T>(string url, T value, CancellationToken cancellationToken = default);
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ece0aeada0b0be4795127847bbe1a16
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f4804b35f0832940a028f2905294829
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -3,7 +3,6 @@ using System.IO;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
public interface INetMessage { }
|
||||
public interface INetMessageReader
|
||||
{
|
||||
void Initialize();
|
||||
@@ -25,11 +24,4 @@ namespace BITKit
|
||||
public abstract void WriteBinary(BinaryWriter writer, T value);
|
||||
public void WriteBinaryAsObject(BinaryWriter writer, object value) => WriteBinary(writer, (T)value);
|
||||
}
|
||||
public interface INetMessager : IDiagnostics
|
||||
{
|
||||
void Init();
|
||||
void Send<T>(T message);
|
||||
void Register<T>(Action<T> action);
|
||||
void UnRegister<T>(Action<T> action);
|
||||
}
|
||||
}
|
@@ -1,65 +0,0 @@
|
||||
#if GameDesigner && UNITY
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
public class NetUtils : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// 客户端调用ServerRpcMyMessage方法
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
public static void ClientInvokeServerRpcMyMessage(string message)
|
||||
{
|
||||
//简化方法
|
||||
ServerRpc<string>(NetUtils.ServerRpcMyMessage,message);
|
||||
//原始方法
|
||||
SendRT(nameof(ServerRpcMyMessage),message);
|
||||
}
|
||||
/// <summary>
|
||||
/// 仅服务器调用该方法
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
[ServerRpc]
|
||||
public static void ServerRpcMyMessage(string message)
|
||||
{
|
||||
ClientRpc<string>(ClientRpcMyMessage,message);
|
||||
}
|
||||
/// <summary>
|
||||
/// 所有客户端调用该方法
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
[ClientRpc]
|
||||
public static void ClientRpcMyMessage(string message)
|
||||
{
|
||||
Debug.Log($"已收到消息:{message}");
|
||||
}
|
||||
public static void InvokeOnServer<T>(Action<T> action, params object[] pars)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void RpcAll(Action<object> obj,params object[] pars)
|
||||
{
|
||||
|
||||
}
|
||||
public static void ClientRpc<T>(Action<T> obj, params object[] pars)
|
||||
{
|
||||
|
||||
}
|
||||
public static void ServerRpc<T>(Action<T> obj, params object[] pars)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void SendRT(string funcName, params object[] pars)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94fe2cdfa3cdec64cb7f3c5a9cd810d9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,12 +0,0 @@
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace BITKit.HttpNet
|
||||
{
|
||||
[System.Serializable]
|
||||
public abstract class WebProvider : IWebProvider
|
||||
{
|
||||
public abstract UniTask<string> GetAsync(string url, CancellationToken cancellationToken = default);
|
||||
public abstract UniTask<string> PostAsync<T>(string url, T value, CancellationToken cancellationToken = default);
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2544cc3cc202eca40ad13f8903375a48
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user