本文整理汇总了C#中Microsoft.Azure.Amqp.Transport.TransportAsyncCallbackArgs.SetBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# TransportAsyncCallbackArgs.SetBuffer方法的具体用法?C# TransportAsyncCallbackArgs.SetBuffer怎么用?C# TransportAsyncCallbackArgs.SetBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Azure.Amqp.Transport.TransportAsyncCallbackArgs
的用法示例。
在下文中一共展示了TransportAsyncCallbackArgs.SetBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClientWebSocketTransportWriteWithoutConnectTest
public void ClientWebSocketTransportWriteWithoutConnectTest()
{
var websocket = new ClientWebSocket();
var clientWebSocketTransport = new ClientWebSocketTransport(websocket, null, null);
var args = new TransportAsyncCallbackArgs();
args.SetBuffer(byteArray, 0, byteArray.Length);
clientWebSocketTransport.WriteAsync(args);
}
示例2: ClientWebSocketTransportReadTest
public void ClientWebSocketTransportReadTest()
{
var websocket = new ClientWebSocket();
var clientWebSocketTransport = new ClientWebSocketTransport(websocket, IotHubName, null, null);
TransportAsyncCallbackArgs args = new TransportAsyncCallbackArgs();
byte[] byteArray = new byte[10];
args.SetBuffer(byteArray, 0, 10);
clientWebSocketTransport.ReadAsync(args);
}
示例3: ClientWebSocketTransportReadWithoutConnectTest
public async Task ClientWebSocketTransportReadWithoutConnectTest()
{
var websocket = new ClientWebSocket();
var clientWebSocketTransport = new ClientWebSocketTransport(websocket, null, null);
var args = new TransportAsyncCallbackArgs();
var byteArray = new byte[10];
args.SetBuffer(byteArray, 0, 10);
if (clientWebSocketTransport.ReadAsync(args))
{
while (!readComplete)
{
Thread.Sleep(TimeSpan.FromSeconds(1));
}
}
await websocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "", CancellationToken.None);
}
示例4: ReadWriteTest
public void ReadWriteTest()
{
var websocket = new ClientWebSocket();
// Set SubProtocol to AMQPWSB10
websocket.Options.AddSubProtocol(WebSocketConstants.SubProtocols.Amqpwsb10);
Uri uri = new Uri("ws://" + IotHubName + ":" + Port + WebSocketConstants.UriSuffix);
websocket.ConnectAsync(uri, CancellationToken.None).Wait(CancellationToken.None);
clientWebSocketTransport = new ClientWebSocketTransport(websocket, IotHubName, null, null);
// Test Write API
TransportAsyncCallbackArgs args = new TransportAsyncCallbackArgs();
args.CompletedCallback = onWriteOperationComplete;
args.SetBuffer(byteArray, 0, byteArray.Length);
clientWebSocketTransport.WriteAsync(args);
// Test Read API
args.CompletedCallback = onReadOperationComplete;
clientWebSocketTransport.ReadAsync(args);
}
示例5: LegacyWebSocketReadWriteTest
public async Task LegacyWebSocketReadWriteTest()
{
var websocket = new IotHubClientWebSocket(WebSocketConstants.SubProtocols.Amqpwsb10);
await websocket.ConnectAsync(IotHubName, Port, "ws://", TimeSpan.FromMinutes(1));
legacyClientWebSocketTransport = new LegacyClientWebSocketTransport(websocket, TimeSpan.FromSeconds(60), null, null);
// Test Write API
TransportAsyncCallbackArgs args = new TransportAsyncCallbackArgs();
args.CompletedCallback = onWriteOperationComplete;
args.SetBuffer(byteArray, 0, byteArray.Length);
legacyClientWebSocketTransport.WriteAsync(args);
// Test Read API
args.CompletedCallback = onReadOperationComplete;
if (legacyClientWebSocketTransport.ReadAsync(args))
{
while (!readComplete)
{
Thread.Sleep(TimeSpan.FromSeconds(1));
}
}
// Once Read operation is complete, close websocket transport
legacyClientWebSocketTransport.CloseAsync(TimeSpan.FromSeconds(30)).Wait(CancellationToken.None);
}
示例6: LegacyWebSocketWriteAfterCloseTest
public async Task LegacyWebSocketWriteAfterCloseTest()
{
var websocket = new IotHubClientWebSocket(WebSocketConstants.SubProtocols.Amqpwsb10);
await websocket.ConnectAsync(IotHubName, Port, "ws://", TimeSpan.FromMinutes(1));
legacyClientWebSocketTransport = new LegacyClientWebSocketTransport(websocket, TimeSpan.FromMinutes(1), null, null);
await legacyClientWebSocketTransport.CloseAsync(TimeSpan.FromSeconds(30));
var args = new TransportAsyncCallbackArgs();
args.SetBuffer(byteArray, 0, byteArray.Length);
legacyClientWebSocketTransport.WriteAsync(args);
}
示例7: LegacyClientWebSocketTransportWriteWithoutConnectTest
public void LegacyClientWebSocketTransportWriteWithoutConnectTest()
{
var websocket = new IotHubClientWebSocket(WebSocketConstants.SubProtocols.Amqpwsb10);
var clientWebSocketTransport = new LegacyClientWebSocketTransport(websocket, TimeSpan.FromSeconds(60), null, null);
var args = new TransportAsyncCallbackArgs();
args.SetBuffer(byteArray, 0, byteArray.Length);
clientWebSocketTransport.WriteAsync(args);
}
示例8: LegacyClientWebSocketTransportReadWithoutConnectTest
public async Task LegacyClientWebSocketTransportReadWithoutConnectTest()
{
var websocket = new IotHubClientWebSocket(WebSocketConstants.SubProtocols.Amqpwsb10);
var clientWebSocketTransport = new LegacyClientWebSocketTransport(websocket, TimeSpan.FromSeconds(60), null, null);
var args = new TransportAsyncCallbackArgs();
var byteArray = new byte[10];
args.SetBuffer(byteArray, 0, 10);
if (clientWebSocketTransport.ReadAsync(args))
{
while (!readComplete)
{
Thread.Sleep(TimeSpan.FromSeconds(1));
}
}
await websocket.CloseAsync();
}
示例9: ReadAfterCloseTest
public async Task ReadAfterCloseTest()
{
var websocket = new ClientWebSocket();
// Set SubProtocol to AMQPWSB10
websocket.Options.AddSubProtocol(WebSocketConstants.SubProtocols.Amqpwsb10);
var uri = new Uri("ws://" + IotHubName + ":" + Port + WebSocketConstants.UriSuffix);
await websocket.ConnectAsync(uri, CancellationToken.None);
clientWebSocketTransport = new ClientWebSocketTransport(websocket, null, null);
await clientWebSocketTransport.CloseAsync(TimeSpan.FromSeconds(30));
var args = new TransportAsyncCallbackArgs();
var byteArray = new byte[10];
args.SetBuffer(byteArray, 0, 10);
args.CompletedCallback = onReadOperationComplete;
clientWebSocketTransport.ReadAsync(args);
}
示例10: WriteAfterAbortTest
public async Task WriteAfterAbortTest()
{
var websocket = new ClientWebSocket();
// Set SubProtocol to AMQPWSB10
websocket.Options.AddSubProtocol(WebSocketConstants.SubProtocols.Amqpwsb10);
Uri uri = new Uri("ws://" + IotHubName + ":" + Port + WebSocketConstants.UriSuffix);
await websocket.ConnectAsync(uri, CancellationToken.None);
clientWebSocketTransport = new ClientWebSocketTransport(websocket, null, null);
clientWebSocketTransport.Abort();
var args = new TransportAsyncCallbackArgs();
args.SetBuffer(byteArray, 0, byteArray.Length);
clientWebSocketTransport.WriteAsync(args);
}
示例11: ReadFrame
public void ReadFrame()
{
TransportAsyncCallbackArgs args = new TransportAsyncCallbackArgs();
args.UserToken = this;
args.SetBuffer(this.sizeBuffer, 0, this.sizeBuffer.Length);
args.CompletedCallback = onSizeComplete;
this.ReadCore(args);
}
示例12: BeginRead
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
#endif
{
TransportAsyncCallbackArgs args = new TransportAsyncCallbackArgs();
args.SetBuffer(buffer, offset, count);
args.CompletedCallback = onIOComplete;
args.UserToken = this;
args.UserToken2 = Tuple.Create(callback, state);
if (!this.transport.ReadAsync(args))
{
Fx.Assert(args.CompletedSynchronously, "args.CompletedSynchronously should be true if not pending");
this.CompleteOperation(args);
}
return args;
}
示例13: ReadWriteAfterAbortTest
public void ReadWriteAfterAbortTest()
{
var websocket = new ClientWebSocket();
// Set SubProtocol to AMQPWSB10
websocket.Options.AddSubProtocol(WebSocketConstants.SubProtocols.Amqpwsb10);
Uri uri = new Uri("ws://" + IotHubName + ":" + Port + WebSocketConstants.UriSuffix);
websocket.ConnectAsync(uri, CancellationToken.None).Wait(CancellationToken.None);
clientWebSocketTransport = new ClientWebSocketTransport(websocket, IotHubName, null, null);
clientWebSocketTransport.Abort();
try
{
TransportAsyncCallbackArgs args = new TransportAsyncCallbackArgs();
args.SetBuffer(byteArray, 0, byteArray.Length);
clientWebSocketTransport.WriteAsync(args);
Assert.Fail("Did not throw object disposed exception");
}
catch(ObjectDisposedException)
{
}
try
{
TransportAsyncCallbackArgs args = new TransportAsyncCallbackArgs();
byte[] byteArray = new byte[10];
args.SetBuffer(byteArray, 0, 10);
clientWebSocketTransport.ReadAsync(args);
Assert.Fail("Did not throw object disposed exception");
}
catch (ObjectDisposedException)
{
}
}
示例14: LegacyWebSocketWriteAfterAbortTest
public async Task LegacyWebSocketWriteAfterAbortTest()
{
var websocket = new IotHubClientWebSocket(WebSocketConstants.SubProtocols.Amqpwsb10);
await websocket.ConnectAsync(IotHubName, Port, "ws://", TimeSpan.FromMinutes(1));
legacyClientWebSocketTransport = new LegacyClientWebSocketTransport(websocket, TimeSpan.FromMinutes(1), null, null);
legacyClientWebSocketTransport.Abort();
var args = new TransportAsyncCallbackArgs();
args.SetBuffer(byteArray, 0, byteArray.Length);
legacyClientWebSocketTransport.WriteAsync(args);
Assert.Fail("Did not throw object disposed exception");
}
示例15: OnWriteHeaderComplete
void OnWriteHeaderComplete(TransportAsyncCallbackArgs args)
{
if (args.Exception != null)
{
this.Complete(args);
return;
}
AmqpTrace.Provider.AmqpLogOperationInformational(this, TraceOperation.Execute, "ReadHeader");
byte[] headerBuffer = new byte[AmqpConstants.ProtocolHeaderSize];
args.SetBuffer(headerBuffer, 0, headerBuffer.Length);
args.CompletedCallback = this.OnReadHeaderComplete;
this.reader.ReadBuffer(args);
}