规范代码,小更新5.8.2

This commit is contained in:
若汝棋茗
2021-11-23 19:24:08 +08:00
parent 0f7f1faad1
commit 1c9fcd9c85
66 changed files with 876 additions and 659 deletions

View File

@@ -357,7 +357,7 @@ namespace RRQMCore.ByteManager
{
throw new RRQMException("内存块已释放");
}
byte[] buffer = new byte[this.length-offset];
byte[] buffer = new byte[this.length - offset];
Array.Copy(this._buffer, offset, buffer, 0, buffer.Length);
return buffer;
}

View File

@@ -1,4 +1,15 @@
namespace RRQMCore.Collections.Concurrent
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
namespace RRQMCore.Collections.Concurrent
{
/// <summary>
/// 队列数据

View File

@@ -1,4 +1,15 @@
using System.Collections.Concurrent;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using System.Collections.Concurrent;
namespace RRQMCore.Collections.Concurrent
{

View File

@@ -1,4 +1,15 @@
using System.Collections.Concurrent;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using System.Collections.Concurrent;
using System.Threading;
namespace RRQMCore.Collections.Concurrent

View File

@@ -1,4 +1,15 @@
using System.Collections.Concurrent;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using System.Collections.Concurrent;
using System.Threading;
namespace RRQMCore.Collections.Concurrent

View File

@@ -1,4 +1,15 @@
using System.Collections.Generic;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using System.Collections.Generic;
namespace RRQMCore
{

View File

@@ -1,4 +1,15 @@
using System;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Net.NetworkInformation;

View File

@@ -1,4 +1,15 @@
using System.Collections.Concurrent;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using System.Collections.Concurrent;
namespace RRQMCore.Helper
{

View File

@@ -1,4 +1,15 @@
using RRQMCore.ByteManager;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore.ByteManager;
using RRQMCore.Serialization;
namespace RRQMCore.Helper

View File

@@ -1,4 +1,15 @@
using System;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using System;
using System.Threading.Tasks;
namespace RRQMCore.Run

View File

@@ -1,4 +1,15 @@
using RRQMCore.Exceptions;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore.Exceptions;
using System;
using System.Threading;
using System.Threading.Tasks;

View File

@@ -1,4 +1,15 @@
namespace RRQMCore.Run
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
namespace RRQMCore.Run
{
/// <summary>
/// 运行状态

View File

@@ -1,4 +1,15 @@
using System;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using System;
namespace RRQMCore.Run
{

View File

@@ -1,4 +1,15 @@
using System;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using System;
namespace RRQMCore.Serialization
{

View File

@@ -17,7 +17,7 @@ namespace RRQMSocket.FileTransfer
/// <summary>
/// 文件终端接口
/// </summary>
public interface IFileClient:IProtocolClient
public interface IFileClient : IProtocolClient
{
/// <summary>
/// 获取当前传输文件信息

View File

@@ -9,7 +9,6 @@
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore;
using RRQMCore.ByteManager;
using RRQMCore.Exceptions;
using RRQMCore.Log;

View File

@@ -759,7 +759,7 @@ namespace RRQMSocket.FileTransfer
/// </summary>
public void StopThisTransfer()
{
this.InternalSend(123,new byte[0]);
this.InternalSend(123, new byte[0]);
}
/// <summary>

View File

@@ -25,7 +25,7 @@ namespace RRQMSocket.RPC.JsonRpc
internal string jsonString;
internal JsonRpcProtocolType protocolType;
internal MethodInvoker methodInvoker;
internal CancellationTokenSource tokenSource= default;
internal CancellationTokenSource tokenSource = default;
/// <summary>
/// Json字符串

View File

@@ -9,9 +9,8 @@
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore.ByteManager;
namespace RRQMSocket.RPC
{
}

View File

@@ -9,7 +9,6 @@
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore;
using RRQMCore.Helper;
using System;
using System.Collections.Generic;

View File

@@ -9,7 +9,6 @@
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;

View File

@@ -9,7 +9,6 @@
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore;
using RRQMCore.Exceptions;
using System;
using System.Collections.Concurrent;

View File

@@ -9,7 +9,6 @@
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore;
using RRQMCore.ByteManager;
using System;
using System.Collections.Generic;
@@ -390,8 +389,8 @@ namespace RRQMSocket.RPC.RRQMRPC
{
socketClient.IDAction = this.IDInvoke;
socketClient.Received += this.OnReceived;
socketClient.BeforeReceiveStream +=this.OnBeforeReceiveStream;
socketClient.ReceivedStream +=this.OnReceivedStream;
socketClient.BeforeReceiveStream += this.OnBeforeReceiveStream;
socketClient.ReceivedStream += this.OnReceivedStream;
socketClient.methodMap = this.MethodMap;
socketClient.executeMethod = this.Execute;
socketClient.serializationSelector = this.serializationSelector;

View File

@@ -9,7 +9,6 @@
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore;
using RRQMCore.ByteManager;
using RRQMCore.Exceptions;
using RRQMCore.Log;

View File

@@ -1,516 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="RRQMSocket.Properties.Resources" Collapsed="true">
<Position X="23.25" Y="2.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAABAAABEAAAAQAAAAAAAAAAAAAAAIA=</HashCode>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.AsyncResult" Collapsed="true">
<Position X="21.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAA=</HashCode>
<FileName>Common\AsyncResult.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.AsyncSender" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="23.25" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAQAAAACiACAAiAAABAAAAAEAAACAAAAVAAAAAIFA=</HashCode>
<FileName>Common\AsyncSender.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" Collapsed="true" />
</Class>
<Class Name="RRQMSocket.CreateOption" Collapsed="true">
<Position X="21.5" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAgAAAAAAAAAAAAAAAAAACAAAAAAAAAAA=</HashCode>
<FileName>Common\CreateOption.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.IPHost" Collapsed="true">
<Position X="23.25" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAQAAEAAAAAAAAKAAAAAAAAAAAAAAAAAE=</HashCode>
<FileName>Common\IPHost.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.ProcotolHelper" Collapsed="true">
<Position X="21.5" Y="2.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAACAAABAAAAA=</HashCode>
<FileName>Common\ProcotolHelper.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.ClientConfig" Collapsed="true">
<Position X="12" Y="12" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Config\ClientConfig.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.ProtocolClientConfig" Collapsed="true">
<Position X="12" Y="16.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Config\ProtocolClientConfig.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.ProtocolServerConfig" Collapsed="true">
<Position X="7.5" Y="16.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAA=</HashCode>
<FileName>Config\ProtocolServerConfig.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.RRQMConfig" Collapsed="true">
<Position X="9.75" Y="10.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAIAAAAAAIAAAAAAgQgAAAAAAAAAAAAAIABAAQAAAA=</HashCode>
<FileName>Config\RRQMConfig.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.ServerConfig" Collapsed="true">
<Position X="8.5" Y="12" Width="1.5" />
<TypeIdentifier>
<HashCode>AAIAAAAAAAAAABCAQAAAAAAAAAAAAAAAQAAgAAAAAAA=</HashCode>
<FileName>Config\ServerConfig.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.TcpClientConfig" Collapsed="true">
<Position X="12" Y="13.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AACAAAAAAAAAAQAAgQAEAAAAAAQAEBAgAAAABACgAAA=</HashCode>
<FileName>Config\TcpClientConfig.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.TcpServerConfig" Collapsed="true">
<Position X="7.5" Y="13.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AQAIAAAAAAAAQAAAAAgQAAAAIAAAAAAAAAAAQCAAAAA=</HashCode>
<FileName>Config\TcpServerConfig.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.TokenClientConfig" Collapsed="true">
<Position X="12" Y="14.75" Width="1.5" />
<TypeIdentifier>
<HashCode>wAAAgAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Config\TokenClientConfig.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.TokenServerConfig" Collapsed="true">
<Position X="7.5" Y="14.75" Width="1.5" />
<TypeIdentifier>
<HashCode>wAAAgAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Config\TokenServerConfig.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.UdpSessionConfig" Collapsed="true">
<Position X="9.75" Y="13.25" Width="1.5" />
<TypeIdentifier>
<HashCode>BAAAAAAAAgAAAAAACAAAAAAAAAAAAAACAAAAAAAAAAA=</HashCode>
<FileName>Config\UdpSessionConfig.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.DataHandlingAdapter" Collapsed="true">
<Position X="5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>IAAAKAABAAIAAAAAAEAAAAAAAAIAAAAIAAAAAAIgAAA=</HashCode>
<FileName>DataAdapter\DataHandlingAdapter.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.FixedHeaderDataHandlingAdapter" Collapsed="true">
<Position X="0.5" Y="1.75" Width="1.5" />
<TypeIdentifier>
<HashCode>gEgAJEAAAAQAAAABAAAAAAAAAAIAACAEAAAAAABAAAA=</HashCode>
<FileName>DataAdapter\FixedHeaderDataHandlingAdapter.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.FixedSizeDataHandlingAdapter" Collapsed="true">
<Position X="2.75" Y="1.75" Width="1.5" />
<TypeIdentifier>
<HashCode>gACAIEAAAAAAAAABAAAAAAAAAAIAAAAEAAAAAAAAAAA=</HashCode>
<FileName>DataAdapter\FixedSizeDataHandlingAdapter.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.JsonStringDataHandlingAdapter" Collapsed="true">
<Position X="5" Y="1.75" Width="1.5" />
<TypeIdentifier>
<HashCode>gAAAIAAAAAAAAAAAAAAABAAAAAIAAAAAAAAAgAAAAAA=</HashCode>
<FileName>DataAdapter\JsonStringDataHandlingAdapter.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.NormalDataHandlingAdapter" Collapsed="true">
<Position X="7.25" Y="1.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAIAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAA=</HashCode>
<FileName>DataAdapter\NormalDataHandlingAdapter.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.TerminatorDataHandlingAdapter" Collapsed="true">
<Position X="9.5" Y="1.75" Width="1.5" />
<TypeIdentifier>
<HashCode>gEAAIEAAAAAAAAAAAAAAAAAAgAIAAAAAAgAAAAEAAAI=</HashCode>
<FileName>DataAdapter\TerminatorDataHandlingAdapter.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.BytesEventArgs" Collapsed="true">
<Position X="4.25" Y="12.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>EventArgs\BytesEventArgs.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.MesEventArgs" Collapsed="true">
<Position X="26.75" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAA=</HashCode>
<FileName>EventArgs\MesEventArgs.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.ReturnBytesEventArgs" Collapsed="true">
<Position X="4.25" Y="14" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>EventArgs\ReturnBytesEventArgs.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.RRQMNotConnectedException" Collapsed="true">
<Position X="25" Y="2.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Exceptions\RRQMNotConnectedException.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.RRQMOverlengthException" Collapsed="true">
<Position X="26.75" Y="2.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Exceptions\RRQMOverlengthException.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.RRQMTimeoutException" Collapsed="true">
<Position X="21.5" Y="3.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Exceptions\RRQMTimeoutException.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.BufferQueue" Collapsed="true">
<Position X="25" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AABAAAABAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>InternalClass\BufferQueue.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.BufferQueueGroup" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="26.75" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAASAAAAAAAAAAAAAAAAAAACAAACEAIAAAAAA=</HashCode>
<FileName>InternalClass\BufferQueueGroup.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" Collapsed="true" />
</Class>
<Class Name="RRQMSocket.SocketClientCollection&lt;T&gt;" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="23.25" Y="3.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAQAAACABQAAACAAAAASAQAAAAAAAAAAEACAAAQA=</HashCode>
<FileName>InternalClass\SocketClientCollection.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" Collapsed="true" />
</Class>
<Class Name="RRQMSocket.Log" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="25" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Logger\Log.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" Collapsed="true" />
</Class>
<Class Name="RRQMSocket.VerifyOption" Collapsed="true">
<Position X="25" Y="3.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AYAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAABAAA=</HashCode>
<FileName>ParameterClass\VerifyOption.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.ProtocolClient" Collapsed="true">
<Position X="12.25" Y="7.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AABAAAAAACBAAAAAEELAAACAEAAAACAAAAAAABQBAAA=</HashCode>
<FileName>TCP\Client\ProtocolClient.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.SimpleProtocolClient" Collapsed="true">
<Position X="12.25" Y="9" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAABAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>TCP\Client\SimpleProtocolClient.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.SimpleTcpClient" Collapsed="true">
<Position X="10" Y="6.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQQAAAA=</HashCode>
<FileName>TCP\Client\SimpleTcpClient.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.SimpleTokenClient" Collapsed="true">
<Position X="14.5" Y="7.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAA=</HashCode>
<FileName>TCP\Client\SimpleTokenClient.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.TcpClient" Collapsed="true">
<Position X="12.25" Y="4.75" Width="1.5" />
<TypeIdentifier>
<HashCode>QAzBAAAAiCgACgQAAEIEUYWAKBgICAAEGCBBBEQhADA=</HashCode>
<FileName>TCP\Client\TcpClient.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="RRQMSocket.TokenClient" Collapsed="true">
<Position X="13.5" Y="6.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAEgAAAAABAgAAAAAAEAICAAAAAAACAAAAAAAAAAgA=</HashCode>
<FileName>TCP\Client\TokenClient.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.ProtocolService&lt;TClient&gt;" Collapsed="true">
<Position X="7.75" Y="7.75" Width="1.5" />
<TypeIdentifier>
<HashCode>BAAAAAAAAABAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>TCP\Service\ProtocolService.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.SimpleProtocolService" Collapsed="true">
<Position X="7.75" Y="9" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAABAAAQQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>TCP\Service\SimpleProtocolService.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.SimpleTcpService" Collapsed="true">
<Position X="3.25" Y="6.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAABAAAQQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>TCP\Service\SimpleTcpService.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.SimpleTokenService" Collapsed="true">
<Position X="5.5" Y="7.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAABAAAQQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>TCP\Service\SimpleTokenService.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.TcpService&lt;TClient&gt;" Collapsed="true">
<Position X="5.5" Y="4.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AUJgAAEACKBgQBCBQkCUABCAUAAEAhIILIAEKAEgKCA=</HashCode>
<FileName>TCP\Service\TcpService.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="RRQMSocket.TokenService&lt;TClient&gt;" Collapsed="true">
<Position X="6.75" Y="6.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAEgAAAAAAAAAABAAAEAACAAAAAAACAAAAAgAAAAAA=</HashCode>
<FileName>TCP\Service\TokenService.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.ProtocolSocketClient" Collapsed="true">
<Position X="16.75" Y="6.25" Width="1.5" />
<TypeIdentifier>
<HashCode>BABgAAAAAABAAAAAEEDAAAAAEAAAAAAAAAAAABQAAAA=</HashCode>
<FileName>TCP\SocketClient\ProtocolSocketClient.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.SimpleProtocolSocketClient" Collapsed="true">
<Position X="16.75" Y="7.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAA=</HashCode>
<FileName>TCP\SocketClient\SimpleProtocolSocketClient.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.SimpleSocketClient" Collapsed="true">
<Position X="19" Y="6.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQQAAAA=</HashCode>
<FileName>TCP\SocketClient\SimpleSocketClient.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.SocketClient" Collapsed="true">
<Position X="18" Y="4.75" Width="1.5" />
<TypeIdentifier>
<HashCode>BghAAAAAAChggAQAAEIEUQSAKABIQEAKCAADACQgAhA=</HashCode>
<FileName>TCP\SocketClient\SocketClient.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="RRQMSocket.SimpleUdpSession" Collapsed="true">
<Position X="1" Y="6.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAA=</HashCode>
<FileName>UDP\SimpleUdpSession.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="RRQMSocket.UdpSession" Collapsed="true">
<Position X="1" Y="4.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AERgAAAASCAAAACACEIAgBiAOACMABIEKAABAAQkIBA=</HashCode>
<FileName>UDP\UdpSession.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="RRQMSocket.BaseSocket" Collapsed="true">
<Position X="10" Y="3.5" Width="1.5" />
<TypeIdentifier>
<HashCode>BAAAAAAAACIAIAAAAAAABAAAAEAAAAAAAAAAAAQAIAA=</HashCode>
<FileName>BaseSocket.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Struct Name="RRQMSocket.AsyncByte" Collapsed="true">
<Position X="21.5" Y="4.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AACAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAABAAAAAAAA=</HashCode>
<FileName>Common\AsyncByte.cs</FileName>
</TypeIdentifier>
</Struct>
<Struct Name="RRQMSocket.ClientBuffer" Collapsed="true">
<Position X="23.25" Y="4.75" Width="1.5" />
<TypeIdentifier>
<HashCode>BAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAABAAAAAA=</HashCode>
<FileName>InternalClass\ClientBuffer.cs</FileName>
</TypeIdentifier>
</Struct>
<Interface Name="RRQMSocket._ITcpService" Collapsed="true">
<Position X="15.5" Y="2" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Interface\_ITcpService.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="RRQMSocket.IClient" Collapsed="true">
<Position X="1.5" Y="7.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AABAAAAAAAAAAAAAAEAAAAAAKAAAAAAACAAAAAAgAAA=</HashCode>
<FileName>Interface\IClient.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="RRQMSocket.IHandleBuffer" Collapsed="true">
<Position X="25" Y="6" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Interface\IHandleBuffer.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="RRQMSocket.IService" Collapsed="true">
<Position X="14.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAACCAAAACAAAAAAAAAAAAAABAAIAAAAAAgIAA=</HashCode>
<FileName>Interface\IService.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="RRQMSocket.ISocket" Collapsed="true">
<Position X="26.75" Y="6" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAA=</HashCode>
<FileName>Interface\ISocket.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="RRQMSocket.ISocketClient" Collapsed="true">
<Position X="1.5" Y="10.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAgAAAAAAAAACAAAAAQAAAAAAAAAAAAAA=</HashCode>
<FileName>Interface\ISocketClient.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="RRQMSocket.ITcpClient" Collapsed="true">
<Position X="1.5" Y="9" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAEEQQAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Interface\ITcpClient.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="RRQMSocket.ITcpService&lt;TClient&gt;" Collapsed="true">
<Position X="13.25" Y="2" Width="1.5" />
<TypeIdentifier>
<HashCode>AQJAAAAAAAAAAAAAAEAQAAAAQAAAAAAABAAEIAAAAAA=</HashCode>
<FileName>Interface\ITcpService.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="RRQMSocket.IUserClient" Collapsed="true">
<Position X="4.5" Y="11" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAACAAAAAAAAAAAAIAAAAgAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Interface\IUserClient.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="RRQMSocket.IUserTcpClient" Collapsed="true">
<Position X="1.5" Y="12.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AASAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Interface\IUserTcpClient.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="RRQMSocket.Pool.IClientGroup" Collapsed="true">
<Position X="21.5" Y="6" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Pool\Interface\IClientGroup.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="RRQMSocket.Pool.IConnectionPool&lt;T&gt;" Collapsed="true">
<Position X="23.25" Y="6" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAIAEAAAIEAAEAACAAAAAAAAAQAAAAAgAAA=</HashCode>
<FileName>Pool\Interface\IConnectionPool.cs</FileName>
</TypeIdentifier>
</Interface>
<Enum Name="RRQMSocket.ServerState" Collapsed="true">
<Position X="21.5" Y="7" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAIAAAAAAECAAA=</HashCode>
<FileName>Enum\ServerState.cs</FileName>
</TypeIdentifier>
</Enum>
<Delegate Name="RRQMMessageEventHandler" Collapsed="true">
<Position X="25" Y="8" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAEAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>DelegateCollection.cs</FileName>
</TypeIdentifier>
</Delegate>
<Delegate Name="RRQMByteBlockEventHandler" Collapsed="true">
<Position X="21.5" Y="8" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>DelegateCollection.cs</FileName>
</TypeIdentifier>
</Delegate>
<Delegate Name="RRQMUDPByteBlockEventHandler" Collapsed="true">
<Position X="21.5" Y="8.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAA=</HashCode>
<FileName>DelegateCollection.cs</FileName>
</TypeIdentifier>
</Delegate>
<Delegate Name="RRQMBytesEventHandler" Collapsed="true">
<Position X="23.25" Y="8" Width="1.5" />
<TypeIdentifier>
<HashCode>AAABAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>DelegateCollection.cs</FileName>
</TypeIdentifier>
</Delegate>
<Delegate Name="RRQMReturnBytesEventHandler" Collapsed="true">
<Position X="26.75" Y="8" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAACAAA=</HashCode>
<FileName>DelegateCollection.cs</FileName>
</TypeIdentifier>
</Delegate>
<Font Name="Microsoft YaHei UI" Size="9" />
</ClassDiagram>

View File

@@ -1,4 +1,15 @@
namespace RRQMSocket
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
namespace RRQMSocket
{
/// <summary>
/// 结果实现类

View File

@@ -10,7 +10,6 @@
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore.Collections.Concurrent;
using System.Collections.Concurrent;
namespace RRQMSocket
{
@@ -21,7 +20,7 @@ namespace RRQMSocket
{
internal BufferQueue()
{
queue = new IntelligentDataQueue<ClientBuffer>(1024*1024*50);
queue = new IntelligentDataQueue<ClientBuffer>(1024 * 1024 * 50);
}
private IntelligentDataQueue<ClientBuffer> queue;

View File

@@ -54,7 +54,7 @@ namespace RRQMSocket
{
this.status = ChannelStatus.Moving;
this.client1 = client;
this.dataQueue = new IntelligentDataQueue<ChannelData>(1024 * 1024 * 20);
this.dataQueue = new IntelligentDataQueue<ChannelData>(cacheCapacity);
this.waitHandle = new AutoResetEvent(false);
this.bytePool = client.BytePool;
this.bufferLength = client.BufferLength;
@@ -64,12 +64,31 @@ namespace RRQMSocket
{
this.status = ChannelStatus.Moving;
this.client2 = client;
this.dataQueue = new IntelligentDataQueue<ChannelData>(1024 * 1024 * 20);
this.dataQueue = new IntelligentDataQueue<ChannelData>(cacheCapacity);
this.waitHandle = new AutoResetEvent(false);
this.bytePool = client.BytePool;
this.bufferLength = client.BufferLength;
}
private static int cacheCapacity = 1024 * 1024 * 20;
/// <summary>
/// 缓存容量
/// </summary>
public static int CacheCapacity
{
get { return cacheCapacity; }
set
{
if (value < 0)
{
value = 1024;
}
cacheCapacity = value;
}
}
/// <summary>
/// 析构函数
/// </summary>
@@ -469,9 +488,9 @@ namespace RRQMSocket
this.waitHandle.Dispose();
this.status = ChannelStatus.Disposed;
this.parent.TryRemove(this.id, out _);
while (this.dataQueue.TryDequeue(out ChannelData channelData))
while (this.dataQueue.TryDequeue(out ChannelData channelData))
{
if (channelData.byteBlock!=null)
if (channelData.byteBlock != null)
{
channelData.byteBlock.SetHolding(false);
}

View File

@@ -18,7 +18,7 @@ namespace RRQMSocket
/// <summary>
/// 处理
/// </summary>
public struct ClientBuffer: IQueueData
public struct ClientBuffer : IQueueData
{
internal IHandleBuffer client;
internal ByteBlock byteBlock;

View File

@@ -0,0 +1,90 @@
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Threading;
namespace RRQMSocket
{
/// <summary>
/// 流量控制
/// </summary>
public class FlowGate
{
/// <summary>
/// 构造函数
/// </summary>
public FlowGate()
{
this.stopwatch = new Stopwatch();
}
private long maximum;
/// <summary>
/// 最大值
/// </summary>
public long Maximum
{
get { return maximum; }
set { maximum = value; }
}
long timeTick;
Stopwatch stopwatch;
long transferLength;
/// <summary>
/// 添加增量
/// </summary>
/// <param name="increment"></param>
public void AddLength(int increment)
{
this.transferLength += increment;
}
/// <summary>
/// 检测等待
/// </summary>
public void CheckWait()
{
if (this.GetNowTick() - timeTick > 0)
{
//时间过了一秒
this.timeTick = GetNowTick();
transferLength = 0;
stopwatch.Restart();
}
else
{
//在这一秒中
if (transferLength > this.maximum)
{
//上传饱和
stopwatch.Stop();
int sleepTime = 1000 - (int)stopwatch.ElapsedMilliseconds <= 0 ? 0 : 1000 - (int)stopwatch.ElapsedMilliseconds;
Thread.Sleep(sleepTime);
}
}
}
/// <summary>
/// 获取当前时间帧
/// </summary>
/// <returns></returns>
private long GetNowTick()
{
return DateTime.Now.Ticks / 10000000;
}
}
}

View File

@@ -1,9 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using System;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace RRQMSocket
{

View File

@@ -1,4 +1,15 @@
using RRQMCore.Run;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore.Run;
namespace RRQMSocket
{

View File

@@ -9,7 +9,6 @@
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore;
using RRQMCore.Dependency;
using RRQMCore.Log;

View File

@@ -1,6 +1,6 @@
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.XREF命名空间的代码归作者本人若汝棋茗所有
// 源代码使用协议遵循本仓库的开源协议及附加协议若本仓库没有设置则按MITClient开源协议授权
// 源代码使用协议遵循本仓库的开源协议及附加协议若本仓库没有设置则按MIT开源协议授权
// CSDN博客https://blog.csdn.net/qq_40374647
// 哔哩哔哩视频https://space.bilibili.com/94253567
// Gitee源代码仓库https://gitee.com/RRQM_Home
@@ -26,7 +26,7 @@ public delegate void RRQMMessageEventHandler<TClient>(TClient client, MesEventAr
/// <param name="socketClient"></param>
/// <param name="protocol"></param>
/// <param name="byteBlock"></param>
public delegate void RRQMProtocolReceivedEventHandler<TClient>(TClient socketClient, short? protocol, ByteBlock byteBlock)where TClient: IProtocolClient;
public delegate void RRQMProtocolReceivedEventHandler<TClient>(TClient socketClient, short? protocol, ByteBlock byteBlock) where TClient : IProtocolClient;
/// <summary>
/// 普通数据
@@ -34,7 +34,7 @@ public delegate void RRQMProtocolReceivedEventHandler<TClient>(TClient socketCli
/// <param name="client"></param>
/// <param name="byteBlock"></param>
/// <param name="obj"></param>
public delegate void RRQMReceivedEventHandler<TClient>(TClient client, ByteBlock byteBlock, object obj)where TClient:IClient;
public delegate void RRQMReceivedEventHandler<TClient>(TClient client, ByteBlock byteBlock, object obj) where TClient : IClient;
/// <summary>
/// 创建时
@@ -48,7 +48,7 @@ public delegate void RRQMCreateSocketClientEventHandler<TClient>(TClient socketC
/// </summary>
/// <param name="socketClient"></param>
/// <param name="e"></param>
public delegate void RRQMStreamOperationEventHandler<TClient>(TClient socketClient, StreamOperationEventArgs e)where TClient: IProtocolClient;
public delegate void RRQMStreamOperationEventHandler<TClient>(TClient socketClient, StreamOperationEventArgs e) where TClient : IProtocolClient;
/// <summary>
/// 流状态

View File

@@ -17,6 +17,11 @@ namespace RRQMSocket
/// </summary>
public enum ChannelStatus : byte
{
/// <summary>
/// 默认
/// </summary>
Default,
/// <summary>
/// 继续下移
/// </summary>

View File

@@ -1,9 +1,15 @@
using RRQMCore.ByteManager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore.ByteManager;
namespace RRQMSocket
{
@@ -16,9 +22,9 @@ namespace RRQMSocket
/// 构造函数
/// </summary>
/// <param name="byteBlock"></param>
public ProtocolSubscriberEventArgs(ByteBlock byteBlock) :base(byteBlock)
{
public ProtocolSubscriberEventArgs(ByteBlock byteBlock) : base(byteBlock)
{
}
/// <summary>

View File

@@ -1,4 +1,15 @@
using RRQMCore;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore;
using System.IO;
namespace RRQMSocket

View File

@@ -1,4 +1,15 @@
using RRQMCore;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore;
using System;
namespace RRQMSocket

View File

@@ -1,4 +1,15 @@
using RRQMCore;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore;
namespace RRQMSocket
{
@@ -23,7 +34,7 @@ namespace RRQMSocket
/// <param name="status"></param>
/// <param name="metadata"></param>
/// <param name="streamInfo"></param>
public StreamStatusEventArgs(ChannelStatus status, Metadata metadata, StreamInfo streamInfo) :base(metadata,streamInfo)
public StreamStatusEventArgs(ChannelStatus status, Metadata metadata, StreamInfo streamInfo) : base(metadata, streamInfo)
{
this.status = status;
}

View File

@@ -10,10 +10,8 @@
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore.ByteManager;
using RRQMCore.Exceptions;
using RRQMCore.Log;
using System;
using System.Net.Sockets;
namespace RRQMSocket
{

View File

@@ -1,4 +1,15 @@
using RRQMCore;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore;
using RRQMCore.ByteManager;
using System.IO;
using System.Threading.Tasks;
@@ -22,6 +33,13 @@ namespace RRQMSocket
/// <returns></returns>
Channel CreateChannel();
/// <summary>
/// 创建通道
/// </summary>
/// <param name="id">指定ID</param>
/// <returns></returns>
Channel CreateChannel(int id);
/// <summary>
/// 移除协议订阅
/// </summary>

View File

@@ -1,4 +1,15 @@
namespace RRQMSocket
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
namespace RRQMSocket
{
/// <summary>
/// 返回通知接口

View File

@@ -1,10 +1,16 @@
using RRQMCore.ByteManager;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore.ByteManager;
using RRQMCore.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RRQMSocket
{

View File

@@ -14,7 +14,7 @@ namespace RRQMSocket
/// <summary>
/// 服务器辅助类接口
/// </summary>
public interface ISocketClient : ITcpClientBase,ISendBase
public interface ISocketClient : ITcpClientBase, ISendBase
{
/// <summary>
/// 用于索引的ID

View File

@@ -1,15 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using System;
namespace RRQMSocket
{
/// <summary>
/// 订阅接口
/// </summary>
public interface ISubscriber:IDisposable
public interface ISubscriber : IDisposable
{
/// <summary>
/// 客户端

View File

@@ -9,7 +9,6 @@
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using System.Collections.Generic;
using System.Net.Sockets;
namespace RRQMSocket

View File

@@ -1,4 +1,15 @@
namespace RRQMSocket
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
namespace RRQMSocket
{
/// <summary>
/// 具有验证功能的终端接口

View File

@@ -1,9 +1,16 @@
using RRQMCore.ByteManager;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore.ByteManager;
using RRQMCore.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

View File

@@ -4,7 +4,7 @@
<ApplicationIcon>RRQM.ico</ApplicationIcon>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>RRQM.pfx</AssemblyOriginatorKeyFile>
<Version>5.8.1</Version>
<Version>5.8.2</Version>
<LangVersion>9.0</LangVersion>
<Company>若汝棋茗</Company>
<Copyright>Copyright © 2021 若汝棋茗</Copyright>

View File

@@ -1,4 +1,15 @@
namespace RRQMSocket
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
namespace RRQMSocket
{
/// <summary>
/// 流信息

View File

@@ -1,4 +1,15 @@
using System.Threading;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using System.Threading;
namespace RRQMSocket
{
@@ -17,6 +28,18 @@ namespace RRQMSocket
private CancellationTokenSource tokenSource;
private int maxSpeed = 1024 * 1024;
/// <summary>
/// 最大传输速度默认1024*1024字节
/// </summary>
public int MaxSpeed
{
get { return maxSpeed; }
set { maxSpeed = value; }
}
/// <summary>
/// 已完成长度
/// </summary>
@@ -31,7 +54,7 @@ namespace RRQMSocket
get { return progress; }
}
private int packageSize=1024*64;
private int packageSize = 1024 * 64;
/// <summary>
/// 包长度默认64Kb
@@ -42,6 +65,15 @@ namespace RRQMSocket
set { packageSize = value; }
}
internal ChannelStatus status;
/// <summary>
/// 状态
/// </summary>
public ChannelStatus Status
{
get { return status; }
}
/// <summary>
/// 可取消令箭

View File

@@ -1,4 +1,15 @@
using RRQMCore;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore;
using RRQMCore.Run;
namespace RRQMSocket

View File

@@ -1,23 +1,30 @@
using RRQMCore.ByteManager;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore.ByteManager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RRQMSocket
{
/// <summary>
/// 协议订阅
/// </summary>
public class ProtocolSubscriber : SubscriberBase, ISendBase, IDisposable
public class ProtocolSubscriber : SubscriberBase, ISendBase, IDisposable
{
/// <summary>
/// 构造函数
/// </summary>
/// <param name="protocol"></param>
/// <param name="receivedAction"></param>
public ProtocolSubscriber(short protocol, Action<ProtocolSubscriber, ProtocolSubscriberEventArgs> receivedAction):base(protocol)
public ProtocolSubscriber(short protocol, Action<ProtocolSubscriber, ProtocolSubscriberEventArgs> receivedAction) : base(protocol)
{
this.Received = receivedAction;
}

View File

@@ -1,10 +1,15 @@
using RRQMCore.Collections.Concurrent;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore.Collections.Concurrent;
namespace RRQMSocket
{

View File

@@ -1,4 +1,15 @@
using System;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using System;
namespace RRQMSocket
{

View File

@@ -1,8 +1,15 @@
using RRQMCore.ByteManager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore.ByteManager;
using System.Threading;
using System.Threading.Tasks;
@@ -11,7 +18,7 @@ namespace RRQMSocket
/// <summary>
/// 协议订阅等待
/// </summary>
public class WaitSenderSubscriber : SubscriberBase, IWaitSender
public class WaitSenderSubscriber : SubscriberBase, ISendBase, IWaitSender
{
/// <summary>
/// 构造函数
@@ -48,6 +55,65 @@ namespace RRQMSocket
}
#pragma warning disable CS1591
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="buffer"></param>
/// <param name="offset"></param>
/// <param name="length"></param>
public void Send(byte[] buffer, int offset, int length)
{
client.Send(this.Protocol, buffer, offset, length);
}
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="buffer"></param>
public void Send(byte[] buffer)
{
this.Send(buffer, 0, buffer.Length);
}
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="byteBlock"></param>
public void Send(ByteBlock byteBlock)
{
this.Send(byteBlock.Buffer, 0, byteBlock.Len);
}
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="buffer"></param>
/// <param name="offset"></param>
/// <param name="length"></param>
public void SendAsync(byte[] buffer, int offset, int length)
{
this.client.SendAsync(this.Protocol, buffer, offset, length);
}
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="buffer"></param>
public void SendAsync(byte[] buffer)
{
this.SendAsync(buffer, 0, buffer.Length);
}
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="byteBlock"></param>
public void SendAsync(ByteBlock byteBlock)
{
this.SendAsync(byteBlock.Buffer, 0, byteBlock.Len);
}
public byte[] SendThenReturn(byte[] buffer, int offset, int length, CancellationToken token = default)
{
lock (this)
@@ -81,7 +147,7 @@ namespace RRQMSocket
public byte[] SendThenReturn(byte[] buffer, CancellationToken token = default)
{
return this.SendThenReturn(buffer,0,buffer.Length,token);
return this.SendThenReturn(buffer, 0, buffer.Length, token);
}
public byte[] SendThenReturn(ByteBlock byteBlock, CancellationToken token = default)
@@ -91,15 +157,15 @@ namespace RRQMSocket
public Task<byte[]> SendThenReturnAsync(byte[] buffer, int offset, int length, CancellationToken token = default)
{
return Task.Run(()=>
{
return this.SendThenReturn(buffer,offset,length,token);
});
return Task.Run(() =>
{
return this.SendThenReturn(buffer, offset, length, token);
});
}
public Task<byte[]> SendThenReturnAsync(byte[] buffer, CancellationToken token = default)
{
return this.SendThenReturnAsync(buffer,0,buffer.Length,token);
return this.SendThenReturnAsync(buffer, 0, buffer.Length, token);
}
public Task<byte[]> SendThenReturnAsync(ByteBlock byteBlock, CancellationToken token = default)

View File

@@ -69,6 +69,24 @@ namespace RRQMSocket
}
}
/// <summary>
/// 创建通道
/// </summary>
/// <param name="id">指定ID</param>
/// <returns></returns>
public Channel CreateChannel(int id)
{
Channel channel = new Channel(this);
if (this.userChannels.TryAdd(id, channel))
{
channel.id = id;
channel.parent = this.userChannels;
this.SocketSend(-2, BitConverter.GetBytes(id));
return channel;
}
throw new RRQMException("指定ID已存在");
}
/// <summary>
/// 释放资源
/// </summary>
@@ -167,10 +185,10 @@ namespace RRQMSocket
}
else
{
ProtocolSubscriberCollection protocolSubscribers= this.protocolSubscriberCollection.GetOrAdd(subscriber.Protocol,(p)=>
{
return new ProtocolSubscriberCollection();
});
ProtocolSubscriberCollection protocolSubscribers = this.protocolSubscriberCollection.GetOrAdd(subscriber.Protocol, (p) =>
{
return new ProtocolSubscriberCollection();
});
subscriber.client = this;
protocolSubscribers.Add(subscriber);
@@ -426,7 +444,7 @@ namespace RRQMSocket
this.SetDataHandlingAdapter(new FixedHeaderDataHandlingAdapter());
}
}
/// <summary>
/// 预处理流数据
/// </summary>
@@ -436,8 +454,8 @@ namespace RRQMSocket
private void P_9_RequestStreamToThis(WaitStream waitStream)
{
StreamOperator streamOperator = new StreamOperator();
StreamInfo streamInfo = new StreamInfo(waitStream.Size,waitStream.StreamType);
StreamOperationEventArgs args = new StreamOperationEventArgs(streamOperator,waitStream.Metadata, streamInfo);
StreamInfo streamInfo = new StreamInfo(waitStream.Size, waitStream.StreamType);
StreamOperationEventArgs args = new StreamOperationEventArgs(streamOperator, waitStream.Metadata, streamInfo);
try
{
@@ -459,6 +477,7 @@ namespace RRQMSocket
if (streamOperator.Token.IsCancellationRequested)
{
channel.Cancel();
streamOperator.status = channel.Status;
break;
}
ByteBlock block = channel.GetCurrentByteBlock();
@@ -473,27 +492,29 @@ namespace RRQMSocket
}
block.SetHolding(false);
}
HandleStream(new StreamStatusEventArgs(channel.Status,args.Metadata, args.StreamInfo) { Bucket = stream, Message = args.Message});
streamOperator.status = channel.Status;
HandleStream(new StreamStatusEventArgs(channel.Status, args.Metadata, args.StreamInfo) { Bucket = stream, Message = args.Message });
});
}
else
{
waitStream.Status = 3;
waitStream.Message = "未设置流容器";
streamOperator.status = ChannelStatus.Error;
}
}
else
{
waitStream.Status = 2;
waitStream.Message = args.Message;
streamOperator.status = ChannelStatus.Cancel;
}
}
catch (Exception ex)
{
streamOperator.status = ChannelStatus.Error;
waitStream.Status = 3;
waitStream.Message = ex.Message;
this.logger.Debug(LogType.Error, this, $"在{nameof(P_9_RequestStreamToThis)}中发生错误。", ex);
}
@@ -887,22 +908,28 @@ namespace RRQMSocket
{
if (this.TrySubscribeChannel(waitStreamResult.ChannelID, out Channel channel))
{
FlowGate flowGate = new FlowGate() { Maximum = streamOperator.MaxSpeed };
while (true)
{
flowGate.CheckWait();
if (streamOperator.Token.IsCancellationRequested)
{
channel.Cancel();
streamOperator.status = channel.Status;
return new AsyncResult(false, "任务已取消");
}
int r = stream.Read(byteBlock.Buffer, 0, length);
if (r <= 0)
{
channel.Complete();
streamOperator.status = channel.Status;
return new AsyncResult(true, $"成功发送");
}
channel.Write(byteBlock.Buffer, 0, r);
flowGate.AddLength(r);
streamOperator.speedTemp += r;
streamOperator.completedLength += r;
streamOperator.progress = (float)((double)streamOperator.completedLength / size);
@@ -911,40 +938,48 @@ namespace RRQMSocket
}
else
{
streamOperator.status = ChannelStatus.Error;
return new AsyncResult(false, $"建立通道失败。");
}
}
else if (waitStreamResult.Status == 2)
{
streamOperator.status = ChannelStatus.Error;
return new AsyncResult(false, $"服务器拒绝接收,反馈信息:{waitStreamResult.Message}");
}
else if (waitStreamResult.Status == 3)
{
streamOperator.status = ChannelStatus.Error;
return new AsyncResult(false, $"服务器异常,信息:{waitStreamResult.Message}");
}
else
{
streamOperator.status = ChannelStatus.Error;
return new AsyncResult(false, "未知状态返回");
}
}
case WaitDataStatus.Overtime:
{
streamOperator.status = ChannelStatus.Timeout;
throw new RRQMTimeoutException();
}
case WaitDataStatus.Canceled:
{
streamOperator.status = ChannelStatus.Cancel;
return new AsyncResult(false, "任务已取消");
}
case WaitDataStatus.Waiting:
case WaitDataStatus.Disposed:
default:
{
streamOperator.status = ChannelStatus.Disposed;
return new AsyncResult(false, "未知错误");
}
}
}
catch (Exception ex)
{
streamOperator.status = ChannelStatus.Error;
return new AsyncResult(false, ex.Message);
}
finally

View File

@@ -0,0 +1,152 @@
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.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
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//using RRQMCore.ByteManager;
//using RRQMCore.Exceptions;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Net;
//using System.Net.Sockets;
//using System.Text;
//using System.Threading;
//using System.Threading.Tasks;
//namespace RRQMSocket
//{
// /// <summary>
// /// 短连接TCP客户端
// /// </summary>
// public class ShortConnectionTcpClient : BaseSocket, ITcpClientBase, IWaitSender
// {
// private string ip;
// private int port;
// private Socket socket;
// private DataHandlingAdapter dataHandlingAdapter;
// /// <summary>
// /// <inheritdoc/>
// /// </summary>
// public string IP => ip;
// /// <summary>
// /// <inheritdoc/>
// /// </summary>
// public int Port => port;
// /// <summary>
// /// 主同信器
// /// </summary>
// public Socket MainSocket => this.socket;
// /// <summary>
// /// <inheritdoc/>
// /// </summary>
// public string Name => $"{this.ip}:{this.port}";
// /// <summary>
// /// <inheritdoc/>
// /// </summary>
// public bool Online => this.socket == null ? false : socket.Connected;
// /// <summary>
// /// <inheritdoc/>
// /// </summary>
// public DataHandlingAdapter DataHandlingAdapter => this.dataHandlingAdapter;
// /// <summary>
// /// <inheritdoc/>
// /// </summary>
// public BytePool BytePool => BytePool.Default;
//#pragma warning disable CS1591
// public byte[] SendThenReturn(byte[] buffer, int offset, int length, CancellationToken token = default)
// {
// throw new NotImplementedException();
// }
// public byte[] SendThenReturn(byte[] buffer, CancellationToken token = default)
// {
// throw new NotImplementedException();
// }
// public byte[] SendThenReturn(ByteBlock byteBlock, CancellationToken token = default)
// {
// throw new NotImplementedException();
// }
// public Task<byte[]> SendThenReturnAsync(byte[] buffer, int offset, int length, CancellationToken token = default)
// {
// throw new NotImplementedException();
// }
// public Task<byte[]> SendThenReturnAsync(byte[] buffer, CancellationToken token = default)
// {
// throw new NotImplementedException();
// }
// public Task<byte[]> SendThenReturnAsync(ByteBlock byteBlock, CancellationToken token = default)
// {
// throw new NotImplementedException();
// }
//#pragma warning restore CS1591
// public void Connect(EndPoint endPoint)
// {
// this.socket = new Socket();
// }
// public void SetDataHandlingAdapter(DataHandlingAdapter adapter)
// {
// if (adapter == null)
// {
// throw new RRQMException("数据处理适配器为空");
// }
// adapter.BytePool = this.BytePool;
// adapter.Logger = this.Logger;
// adapter.ReceivedCallBack = this.HandleReceivedData;
// adapter.SendCallBack = this.Sent;
// this.dataHandlingAdapter = adapter;
// }
// private void HandleReceivedData(ByteBlock byteBlock, object obj)
// {
// }
// private void Sent(byte[] buffer, int offset, int length, bool isAsync)
// {
// if (!this.Online)
// {
// throw new RRQMNotConnectedException("该实例已断开");
// }
// if (isAsync)
// {
// this.socket.BeginSend(buffer, offset, length, SocketFlags.None, null, null);
// }
// else
// {
// while (length > 0)
// {
// int r = MainSocket.Send(buffer, offset, length, SocketFlags.None);
// if (r == 0 && length > 0)
// {
// throw new RRQMException("发送数据不完全");
// }
// offset += r;
// length -= r;
// }
// }
// }
// }
//}

View File

@@ -10,7 +10,6 @@
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore.ByteManager;
using System;
namespace RRQMSocket
{
@@ -39,9 +38,9 @@ namespace RRQMSocket
/// </summary>
/// <param name="procotol"></param>
/// <param name="byteBlock"></param>
protected override void HandleProtocolData(short? procotol, ByteBlock byteBlock)
protected override void HandleProtocolData(short? procotol, ByteBlock byteBlock)
{
this.Received.Invoke(this,procotol, byteBlock);
this.Received.Invoke(this, procotol, byteBlock);
}
/// <summary>

View File

@@ -10,7 +10,6 @@
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore.ByteManager;
using System;
namespace RRQMSocket
{
@@ -29,7 +28,7 @@ namespace RRQMSocket
/// </summary>
/// <param name="byteBlock"></param>
/// <param name="obj"></param>
protected override void HandleReceivedData(ByteBlock byteBlock, object obj)
protected override void HandleReceivedData(ByteBlock byteBlock, object obj)
{
OnReceived(byteBlock, obj);
}
@@ -41,7 +40,7 @@ namespace RRQMSocket
/// <param name="obj"></param>
protected virtual void OnReceived(ByteBlock byteBlock, object obj)
{
this.Received?.Invoke(this,byteBlock, obj);
this.Received?.Invoke(this, byteBlock, obj);
}
}
}

View File

@@ -10,7 +10,6 @@
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore.ByteManager;
using System;
namespace RRQMSocket
{
@@ -31,7 +30,7 @@ namespace RRQMSocket
/// <param name="obj"></param>
protected sealed override void HandleReceivedData(ByteBlock byteBlock, object obj)
{
this.Received?.Invoke(this,byteBlock, obj);
this.Received?.Invoke(this, byteBlock, obj);
}
}
}

View File

@@ -10,7 +10,6 @@
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore.ByteManager;
using System;
namespace RRQMSocket
{
@@ -49,7 +48,7 @@ namespace RRQMSocket
protected override void OnCreateSocketClient(SimpleProtocolSocketClient socketClient, CreateOption createOption)
{
this.CreateSocketClient?.Invoke(socketClient, createOption);
socketClient.Received +=this.OnReceive;
socketClient.Received += this.OnReceive;
socketClient.BeforeReceiveStream += this.OnBeforeReceiveStream;
socketClient.ReceivedStream += this.OnReceivedStream;
}

View File

@@ -10,7 +10,6 @@
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore.ByteManager;
using System;
namespace RRQMSocket
{

View File

@@ -433,22 +433,27 @@ namespace RRQMSocket
{
if (this.TrySubscribeChannel(waitStreamResult.ChannelID, out Channel channel))
{
FlowGate flowGate = new FlowGate() { Maximum = streamOperator.MaxSpeed };
while (true)
{
flowGate.CheckWait();
if (streamOperator.Token.IsCancellationRequested)
{
channel.Cancel();
streamOperator.status = channel.Status;
return new AsyncResult(false, "任务已取消");
}
int r = stream.Read(byteBlock.Buffer, 0, length);
if (r <= 0)
{
channel.Complete();
streamOperator.status = channel.Status;
break;
}
channel.Write(byteBlock.Buffer, 0, r);
flowGate.AddLength(r);
streamOperator.speedTemp += r;
streamOperator.completedLength += r;
streamOperator.progress = (float)((double)streamOperator.completedLength / size);
@@ -457,40 +462,48 @@ namespace RRQMSocket
}
else
{
streamOperator.status = ChannelStatus.Error;
return new AsyncResult(false, $"建立通道失败。");
}
}
else if (waitStreamResult.Status == 2)
{
streamOperator.status = ChannelStatus.Error;
return new AsyncResult(false, $"服务器拒绝接收,反馈信息:{waitStreamResult.Message}");
}
else if (waitStreamResult.Status == 3)
{
streamOperator.status = ChannelStatus.Error;
return new AsyncResult(false, $"服务器异常,信息:{waitStreamResult.Message}");
}
else
{
streamOperator.status = ChannelStatus.Error;
return new AsyncResult(false, "未知状态返回");
}
}
case WaitDataStatus.Overtime:
{
streamOperator.status = ChannelStatus.Timeout;
throw new RRQMTimeoutException();
}
case WaitDataStatus.Canceled:
{
streamOperator.status = ChannelStatus.Cancel;
return new AsyncResult(false, "任务已取消");
}
case WaitDataStatus.Waiting:
case WaitDataStatus.Disposed:
default:
{
streamOperator.status = ChannelStatus.Disposed;
return new AsyncResult(false, "未知错误");
}
}
}
catch (Exception ex)
{
streamOperator.status = ChannelStatus.Error;
return new AsyncResult(false, ex.Message);
}
finally
@@ -566,6 +579,25 @@ namespace RRQMSocket
}
}
}
/// <summary>
/// 创建通道
/// </summary>
/// <param name="id">指定ID</param>
/// <returns></returns>
public Channel CreateChannel(int id)
{
Channel channel = new Channel(this);
if (this.userChannels.TryAdd(id, channel))
{
channel.id = id;
channel.parent = this.userChannels;
this.SocketSend(-2, BitConverter.GetBytes(id));
return channel;
}
throw new RRQMException("指定ID已存在");
}
/// <summary>
/// 移除协议订阅
/// </summary>
@@ -868,12 +900,13 @@ namespace RRQMSocket
if (streamOperator.Token.IsCancellationRequested)
{
channel.Cancel();
streamOperator.status = channel.Status;
break;
}
ByteBlock block = channel.GetCurrentByteBlock();
block.Pos = 6;
if (block.TryReadBytesPackageInfo(out int pos,out int len))
if (block.TryReadBytesPackageInfo(out int pos, out int len))
{
stream.Write(block.Buffer, pos, len);
streamOperator.speedTemp += len;
@@ -882,24 +915,27 @@ namespace RRQMSocket
}
block.SetHolding(false);
}
streamOperator.status = channel.Status;
HandleStream(new StreamStatusEventArgs(channel.Status, args.Metadata, args.StreamInfo) { Bucket = stream, Message = args.Message });
});
}
else
{
streamOperator.status = ChannelStatus.Error;
waitStream.Status = 3;
waitStream.Message = "未设置流容器";
}
}
else
{
streamOperator.status = ChannelStatus.Error;
waitStream.Status = 2;
waitStream.Message = args.Message;
}
}
catch (Exception ex)
{
streamOperator.status = ChannelStatus.Error;
waitStream.Status = 3;
waitStream.Message = ex.Message;
@@ -911,14 +947,14 @@ namespace RRQMSocket
this.SocketSend(-8, byteBlock.Buffer, 0, byteBlock.Pos);
}
private void ReceivedChannelData(int id, short type,ByteBlock byteBlock)
private void ReceivedChannelData(int id, short type, ByteBlock byteBlock)
{
if (this.userChannels.TryGetValue(id, out Channel channel))
{
ChannelData channelData = new ChannelData();
channelData.type = type;
if (byteBlock!=null)
if (byteBlock != null)
{
byteBlock.SetHolding(true);
channelData.byteBlock = byteBlock;

View File

@@ -10,7 +10,6 @@
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
using RRQMCore.ByteManager;
using System;
namespace RRQMSocket
{

View File

@@ -50,7 +50,7 @@ namespace RRQMSocket
/// <summary>
/// 获取内存池实例
/// </summary>
public BytePool BytePool{ get { return this.queueGroup == null ? BytePool.Default : this.queueGroup.bytePool; } }
public BytePool BytePool { get { return this.queueGroup == null ? BytePool.Default : this.queueGroup.bytePool; } }
/// <summary>
/// 选择清理类型