//------------------------------------------------------------------------------ // 此代码版权(除特别声明或在XREF结尾的命名空间的代码)归作者本人若汝棋茗所有 // 源代码使用协议遵循本仓库的开源协议及附加协议,若本仓库没有设置,则按MIT开源协议授权 // CSDN博客:https://blog.csdn.net/qq_40374647 // 哔哩哔哩视频:https://space.bilibili.com/94253567 // Gitee源代码仓库:https://gitee.com/RRQM_Home // Github源代码仓库:https://github.com/RRQM // API首页:https://www.yuque.com/rrqm/touchsocket/index // 交流QQ群:234762506 // 感谢您的下载和使用 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ using System.Threading.Tasks; using TouchSocket.Core; using TouchSocket.Sockets; namespace TouchSocket.Rpc.TouchRpc { /// /// WSTouchRpc插件基类 /// public partial class WSTouchRpcPluginBase :PluginBase, ITouchRpcPlugin, IDisconnectedPlguin where TClient: IWSTouchRpcClientBase { #region 虚函数 /// /// 在断开连接时 /// /// /// protected virtual void OnDisconnected(TClient client, DisconnectEventArgs e) { } /// /// 会话断开后触发 /// /// /// /// protected virtual Task OnDisconnectedAsync(TClient client, DisconnectEventArgs e) { return EasyTask.CompletedTask; } /// /// 当文件传输结束之后。并不意味着完成传输,请通过属性值进行判断。 /// /// /// protected virtual void OnFileTransfered(TClient client, FileTransferStatusEventArgs e) { } /// /// 当文件传输结束之后。并不意味着完成传输,请通过属性值进行判断。 /// /// /// /// protected virtual Task OnFileTransferedAsync(TClient client, FileTransferStatusEventArgs e) { return EasyTask.CompletedTask; } /// /// 在文件传输即将进行时触发。 /// /// /// protected virtual void OnFileTransfering(TClient client, FileOperationEventArgs e) { } /// /// 在文件传输即将进行时触发。 /// /// /// /// protected virtual Task OnFileTransferingAsync(TClient client, FileOperationEventArgs e) { return EasyTask.CompletedTask; } /// /// 在完成握手连接时。 /// /// /// protected virtual void OnHandshaked(TClient client, VerifyOptionEventArgs e) { } /// /// 在完成握手连接时。 /// /// /// /// protected virtual Task OnHandshakedAsync(TClient client, VerifyOptionEventArgs e) { return EasyTask.CompletedTask; } /// /// 在验证Token时 /// /// /// protected virtual void OnHandshaking(TClient client, VerifyOptionEventArgs e) { } /// /// 在验证Token时 /// /// /// /// protected virtual Task OnHandshakingAsync(TClient client, VerifyOptionEventArgs e) { return EasyTask.CompletedTask; } /// /// 收到协议数据 /// /// /// protected virtual void OnReceivedProtocolData(TClient client, ProtocolDataEventArgs e) { } /// /// 收到协议数据 /// /// /// /// protected virtual Task OnReceivedProtocolDataAsync(TClient client, ProtocolDataEventArgs e) { return EasyTask.CompletedTask; } /// /// 当需要转发路由包时 /// /// /// protected virtual void OnRouting(TClient client, PackageRouterEventArgs e) { } /// /// 当需要转发路由包时 /// /// /// /// protected virtual Task OnRoutingAsync(TClient client, PackageRouterEventArgs e) { return EasyTask.CompletedTask; } /// /// 流数据处理,用户需要在此事件中对e.Bucket手动释放。 /// /// /// protected virtual void OnStreamTransfered(TClient client, StreamStatusEventArgs e) { } /// /// 流数据处理,用户需要在此事件中对e.Bucket手动释放。 /// /// /// /// protected virtual Task OnStreamTransferedAsync(TClient client, StreamStatusEventArgs e) { return EasyTask.CompletedTask; } /// /// 即将接收流数据,用户需要在此事件中对e.Bucket初始化。 /// /// /// protected virtual void OnStreamTransfering(TClient client, StreamOperationEventArgs e) { } /// /// 即将接收流数据,用户需要在此事件中对e.Bucket初始化。 /// /// /// /// protected virtual Task OnStreamTransferingAsync(TClient client, StreamOperationEventArgs e) { return EasyTask.CompletedTask; } #endregion 虚函数 void IDisconnectedPlguin.OnDisconnected(object client, DisconnectEventArgs e) { OnDisconnected((TClient)client, e); } Task IDisconnectedPlguin.OnDisconnectedAsync(object client, DisconnectEventArgs e) { return OnDisconnectedAsync((TClient)client, e); } void ITouchRpcPlugin.OnFileTransfered(ITouchRpc client, FileTransferStatusEventArgs e) { OnFileTransfered((TClient)client, e); } Task ITouchRpcPlugin.OnFileTransferedAsync(ITouchRpc client, FileTransferStatusEventArgs e) { return OnFileTransferedAsync((TClient)client, e); } void ITouchRpcPlugin.OnFileTransfering(ITouchRpc client, FileOperationEventArgs e) { OnFileTransfering((TClient)client, e); } Task ITouchRpcPlugin.OnFileTransferingAsync(ITouchRpc client, FileOperationEventArgs e) { return OnFileTransferingAsync((TClient)client, e); } void ITouchRpcPlugin.OnHandshaked(ITouchRpc client, VerifyOptionEventArgs e) { OnHandshaked((TClient)client, e); } Task ITouchRpcPlugin.OnHandshakedAsync(ITouchRpc client, VerifyOptionEventArgs e) { return OnHandshakedAsync((TClient)client, e); } void ITouchRpcPlugin.OnHandshaking(ITouchRpc client, VerifyOptionEventArgs e) { OnHandshaking((TClient)client, e); } Task ITouchRpcPlugin.OnHandshakingAsync(ITouchRpc client, VerifyOptionEventArgs e) { return OnHandshakingAsync((TClient)client, e); } void ITouchRpcPlugin.OnReceivedProtocolData(ITouchRpc client, ProtocolDataEventArgs e) { OnReceivedProtocolData((TClient)client, e); } Task ITouchRpcPlugin.OnReceivedProtocolDataAsync(ITouchRpc client, ProtocolDataEventArgs e) { return OnReceivedProtocolDataAsync((TClient)client, e); } void ITouchRpcPlugin.OnRouting(ITouchRpc client, PackageRouterEventArgs e) { OnRouting((TClient)client, e); } Task ITouchRpcPlugin.OnRoutingAsync(ITouchRpc client, PackageRouterEventArgs e) { return OnRoutingAsync((TClient)client, e); } void ITouchRpcPlugin.OnStreamTransfered(ITouchRpc client, StreamStatusEventArgs e) { OnStreamTransfered((TClient)client, e); } Task ITouchRpcPlugin.OnStreamTransferedAsync(ITouchRpc client, StreamStatusEventArgs e) { return OnStreamTransferedAsync((TClient)client, e); } void ITouchRpcPlugin.OnStreamTransfering(ITouchRpc client, StreamOperationEventArgs e) { OnStreamTransfering((TClient)client, e); } Task ITouchRpcPlugin.OnStreamTransferingAsync(ITouchRpc client, StreamOperationEventArgs e) { return OnStreamTransferingAsync((TClient)client, e); } } }