当前位置: 首页>>代码示例>>C#>>正文


C# TransportAsyncCallbackArgs.SetBuffer方法代码示例

本文整理汇总了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);
 }
开发者ID:pierreca,项目名称:azure-iot-sdks,代码行数:8,代码来源:ClientWebSocketTransportTests.cs

示例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);
 }
开发者ID:stefangordon,项目名称:azure-iot-sdks,代码行数:9,代码来源:ClientWebSocketTransportTests.cs

示例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);
        }
开发者ID:pierreca,项目名称:azure-iot-sdks,代码行数:17,代码来源:ClientWebSocketTransportTests.cs

示例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);
        }
开发者ID:stefangordon,项目名称:azure-iot-sdks,代码行数:19,代码来源:ClientWebSocketTransportTests.cs

示例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);
        }
开发者ID:pierreca,项目名称:azure-iot-sdks,代码行数:26,代码来源:ClientWebSocketTransportTests.cs

示例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);
 }
开发者ID:pierreca,项目名称:azure-iot-sdks,代码行数:10,代码来源:ClientWebSocketTransportTests.cs

示例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);
 }
开发者ID:pierreca,项目名称:azure-iot-sdks,代码行数:8,代码来源:ClientWebSocketTransportTests.cs

示例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();
        }
开发者ID:pierreca,项目名称:azure-iot-sdks,代码行数:17,代码来源:ClientWebSocketTransportTests.cs

示例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);
        }
开发者ID:pierreca,项目名称:azure-iot-sdks,代码行数:16,代码来源:ClientWebSocketTransportTests.cs

示例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);
 }
开发者ID:pierreca,项目名称:azure-iot-sdks,代码行数:13,代码来源:ClientWebSocketTransportTests.cs

示例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);
 }
开发者ID:Azure,项目名称:azure-amqp,代码行数:8,代码来源:AsyncIO.cs

示例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;
        }
开发者ID:Azure,项目名称:azure-amqp,代码行数:16,代码来源:TransportStream.cs

示例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)
            {

            }
        }
开发者ID:stefangordon,项目名称:azure-iot-sdks,代码行数:35,代码来源:ClientWebSocketTransportTests.cs

示例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");
        }
开发者ID:pierreca,项目名称:azure-iot-sdks,代码行数:12,代码来源:ClientWebSocketTransportTests.cs

示例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);
        }
开发者ID:Azure,项目名称:azure-amqp,代码行数:14,代码来源:AmqpTransportInitiator.cs


注:本文中的Microsoft.Azure.Amqp.Transport.TransportAsyncCallbackArgs.SetBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。