//------------------------------------------------------------------------------ // 此代码版权(除特别声明或在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; using TouchSocket.Sockets; namespace TouchSocket.Rpc.TouchRpc { /// /// 具有委托能力的插件 /// public sealed partial class TouchRpcActionPlugin : TouchRpcPluginBase where TClient : ITouchRpc { private Action m_fileTransfered; private Action m_fileTransfering; private Action m_handshaked; private Action m_handshaking; private Action m_receivedProtocolData; private Action m_streamTransfered; private Action m_streamTransfering; /// /// SetFileTransfered /// /// /// public TouchRpcActionPlugin SetFileTransfered(Action action) { m_fileTransfered = action; return this; } /// /// SetFileTransfering /// /// /// public TouchRpcActionPlugin SetFileTransfering(Action action) { m_fileTransfering = action; return this; } /// /// SetHandshaked /// /// /// public TouchRpcActionPlugin SetHandshaked(Action action) { m_handshaked = action; return this; } /// /// SetHandshaking /// /// /// public TouchRpcActionPlugin SetHandshaking(Action action) { m_handshaking = action; return this; } /// /// SetReceivedProtocolData /// /// /// public TouchRpcActionPlugin SetReceivedProtocolData(Action action) { m_receivedProtocolData = action; return this; } /// /// SetStreamTransfered /// /// /// public TouchRpcActionPlugin SetStreamTransfered(Action action) { m_streamTransfered = action; return this; } /// /// SetStreamTransfering /// /// /// public TouchRpcActionPlugin SetStreamTransfering(Action action) { m_streamTransfering = action; return this; } #region 重写 /// /// /// /// /// protected override void OnFileTransfered(ITouchRpc client, FileTransferStatusEventArgs e) { m_fileTransfered?.Invoke((TClient)client, e); } /// /// /// /// /// protected override void OnFileTransfering(ITouchRpc client, FileOperationEventArgs e) { m_fileTransfering?.Invoke((TClient)client, e); } /// /// /// /// /// protected override void OnHandshaked(ITouchRpc client, VerifyOptionEventArgs e) { m_handshaked?.Invoke((TClient)client, e); } /// /// /// /// /// protected override void OnHandshaking(ITouchRpc client, VerifyOptionEventArgs e) { m_handshaking?.Invoke((TClient)client, e); } /// /// /// /// /// protected override void OnReceivedProtocolData(ITouchRpc client, ProtocolDataEventArgs e) { m_receivedProtocolData?.Invoke((TClient)client, e); } /// /// /// /// /// protected override void OnStreamTransfered(ITouchRpc client, StreamStatusEventArgs e) { m_streamTransfered?.Invoke((TClient)client, e); } /// /// /// /// /// protected override void OnStreamTransfering(ITouchRpc client, StreamOperationEventArgs e) { m_streamTransfering?.Invoke((TClient)client, e); } #endregion 重写 } }