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 79073df commit 17d757a
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 151 deletions.
9 changes: 8 additions & 1 deletion Megumin.Remote/Transport/BaseTransport.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
namespace Megumin.Remote
using Net.Remote;

namespace Megumin.Remote
{
public class BaseTransport
{
public RpcRemote RemoteCore { get; set; }
public System.Diagnostics.TraceListener TraceListener { get; set; }

public virtual bool ReConnectFrom(ITransportable transportable)
{
return true;
}
}
}

Expand Down
23 changes: 14 additions & 9 deletions Megumin.Remote/Transport/TcpTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,23 @@ public void Disconnect(bool triggerOnDisConnect = false, bool waitSendQueue = fa
/// <para/> 只有方法2成立。重连后需要进行验证流程,需要收发消息甚至rpc功能,需要使用remote功能,所以1不成立。
/// <para/> 收发消息后,socket ReceiveAsync已经挂起,socket已经和remote绑定,不能切换socket,所以方法3不成立。
/// </remarks>
public virtual void ReConnectFrom(TcpTransport oldRemote)
public override bool ReConnectFrom(ITransportable transportable)
{
if (oldRemote == null)
if (transportable is TcpTransport oldRemote)
{
return;
oldRemote.StopSocketSend();
this.StopSocketSend();
//SendPipe 应该和 RpcLayer,待发送消息和rpc回调时对应关系。
//但是既不能将SendPipe 放到RpcRemote中,也不能将RpcLayer放到Transport中,只能这样将就。
SendPipe = oldRemote.SendPipe;
RemoteCore.RpcLayer = oldRemote.RemoteCore.RpcLayer;
StartSocketSend();
return true;
}
else
{
throw new ArgumentException();
}

oldRemote.StopSocketSend();
this.StopSocketSend();
SendPipe = oldRemote.SendPipe;
RemoteCore = oldRemote.RemoteCore;
StartSocketSend();
}
}

Expand Down
7 changes: 7 additions & 0 deletions NetRemoteStandard/ITransportable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ public interface ITransportable : IConnectable, ISocketSendable
/// 当前是否正常工作
/// </summary>
bool IsVaild { get; }

/// <summary>
/// 断线重连
/// </summary>
/// <param name="transportable"></param>
/// <returns></returns>
bool ReConnectFrom(ITransportable transportable);
}
}

Expand Down
Loading

0 comments on commit 17d757a

Please sign in to comment.