Skip to content

Commit

Permalink
增加unity测试
Browse files Browse the repository at this point in the history
  • Loading branch information
KumoKyaku committed Oct 16, 2022
1 parent 17d757a commit bc02127
Show file tree
Hide file tree
Showing 34 changed files with 11,863 additions and 320 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
-->

---
## [3.0.0] - 2022-10-16

### Added
- 从Remote拆分IDisconnectHandler。
- 从Remote拆分Transport。
### Changed
- 公开大部分Remote 中间处理过程 API。
- 整理ITransportable 和 IRemote 和 IListener接口
- 重命名 interface ISendCanAwaitable -> ISendAsyncable
### Deprecated
### Removed
### Fixed
- 修复Tcp半包假死BUG。
- 调整 void Send<T>(T message, int rpcID, object options = null) 参数顺序,消除Rpc send reply 二义性。
### Security

## [2.1.0] - 2022-10-04
### Added
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
~~由于使用了C# 7.3语法,在unity中如果使用源码至少需要2018.3。~~
目标框架netstandard2.1,在unity中建议unity版本2021.2以上。过小的版本可以使用源码,但需要自行解决依赖关系。

# UPM Package
## Install via git URL
![image](https://user-images.githubusercontent.com/46207/79450714-3aadd100-8020-11ea-8aae-b8d87fc4d7be.png)

or add `"com.megumin.net": "https://github.com/KumoKyaku/Megumin.Net.git?path=UnityPackage/Packages/Net"` to `Packages/manifest.json`.

>If you want to set a target version, uses the `*.*.*` release tag so you can specify a version like `#2.1.0`. For example `https://github.com/KumoKyaku/Megumin.Net.git?path=UnityPackage/Packages/Net#2.1.0`.
# 优势
- 支持Tcp,Udp,Kcp。
- 使用内存池和多线程处理收发,可配置线程调度,无需担心网络模块性能问题。
Expand Down
23 changes: 1 addition & 22 deletions UnityPackage/Assets/Down.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,6 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 4719638640884593875}
- component: {fileID: 4719638640884593874}
m_Layer: 5
m_Name: Down
m_TagString: Untagged
Expand Down Expand Up @@ -510,26 +509,6 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &4719638640884593874
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4719638640884593872}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 502824a48032a1040a9eb36b00c6fb64, type: 3}
m_Name:
m_EditorClassIdentifier:
inputIP: {fileID: 4719638642204526454}
inputPort: {fileID: 4719638642098904941}
localIP: {fileID: 4719638641995141201}
localPort: {fileID: 4719638641549124820}
globalIP: {fileID: 4719638641982320754}
globalPort: {fileID: 4719638642719861915}
Send: {fileID: 4719638640879706388}
PingText: {fileID: 1488276339577847404}
--- !u!1 &4719638640912843355
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1204,7 +1183,7 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 4719638640884593874}
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName: UdpSocketTest, Assembly-CSharp
m_MethodName: GetIP
m_Mode: 1
Expand Down
50 changes: 50 additions & 0 deletions UnityPackage/Assets/Message.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System.Collections;
using System.Collections.Generic;
using Megumin;
using Megumin.Message;
using Megumin.Remote;
using ProtoBuf;
using UnityEngine;

[MSGID(1001)]
[ProtoContract]
public class Login
{
[ProtoMember(1)]
public string IP { get; set; }
}

[MSGID(1002)]
public class LoginResult
{
[ProtoMember(1)]
public string TempKey { get; set; }
}

public class Message : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{

}

[Button]
public void Test()
{
Protobuf_netLUT.Regist<Login>();
Protobuf_netLUT.Regist<LoginResult>();

Login login = new Login() { IP = "test" };
MessageLUTTestBuffer buffer = new MessageLUTTestBuffer();
var msgid = Protobuf_netLUT.Serialize(buffer,login);
var login2 = Protobuf_netLUT.Deserialize(msgid, buffer.ReadOnlySequence) as Login;
Debug.Log($"{msgid}--{login.IP}--{login2.IP}");
}
}
11 changes: 11 additions & 0 deletions UnityPackage/Assets/Message.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions UnityPackage/Assets/Plugins.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
33 changes: 33 additions & 0 deletions UnityPackage/Assets/Plugins/Megumin.Protobuf-netLUT.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
7 changes: 7 additions & 0 deletions UnityPackage/Assets/Plugins/Megumin.Protobuf-netLUT.pdb.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions UnityPackage/Assets/Plugins/Megumin.Protobuf-netLUT.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions UnityPackage/Assets/Plugins/Megumin.Protobuf-netLUT.xml.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
33 changes: 33 additions & 0 deletions UnityPackage/Assets/Plugins/System.Collections.Immutable.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bc02127

Please sign in to comment.