async Task <byte[]> IEasyChannel.SendAsync([NotNull] byte[] buffer, PacketOptions options, int millisecondsTimeout) { if (buffer is null) { throw new ArgumentNullException(nameof(buffer)); } ProtocolPacket packet = CreatePacket(buffer, options); return(await _easyBase.SendAsync(packet, ConnectOptions.RemoteEndPoint, millisecondsTimeout)); }
private ProtocolPacket CreatePacket(byte[] buffer, PacketOptions options) { return(new ProtocolPacket { Ip = _localEndPoint.Address.GetAddressBytes(), Port = _localEndPoint.Port, Data = buffer, PacketMode = PacketMode.Request, IsCompress = options?.CompressBuffer ?? false, HasResponse = options?.HasResponse ?? true }); }
public async Task SendAsync([NotNull] byte[] buffer, PacketOptions options, int millisecondsTimeout = -1) { if (buffer is null) { throw new ArgumentNullException(nameof(buffer)); } _basePacket.Data = buffer; _basePacket.PacketMode = PacketMode.Request; _basePacket.HasResponse = options?.HasResponse ?? true; _basePacket.IsCompress = options?.CompressBuffer ?? false; await _sendFunc.Invoke(_basePacket, millisecondsTimeout); }
private ProtocolPacket CreatePacket(byte[] buffer, PacketOptions options) { ProtocolPacket packet = new ProtocolPacket { Ip = ((IPEndPoint)_tcpClient.Client.LocalEndPoint).Address.GetAddressBytes(), Port = ((IPEndPoint)_tcpClient.Client.LocalEndPoint).Port, Data = buffer, PacketMode = PacketMode.Request, IsCompress = options?.CompressBuffer ?? false, HasResponse = options?.HasResponse ?? true, ReportArrived = false }; return(packet); }
async Task <byte[]> IEasyHost.SendAsync([NotNull] byte[] buffer, PacketOptions options, int millisecondsTimeout) { if (buffer is null) { throw new ArgumentNullException(nameof(buffer)); } ProtocolPacket packet = CreatePacket(buffer, options); _tcpChannels.Keys.AsParallel().ForAll(async i => { await i._easyBase.SendAsync(packet, ConnectOptions.RemoteEndPoint, millisecondsTimeout); }); return(await Task.FromResult(new byte[0])); }