Exemple #1
0
        protected override void AioCallback(IntPtr argument)
        {
            var res = Unit.Ok;

            switch (State)
            {
            case AsyncState.Recv:
                res = Aio.GetResult();
                if (res.IsErr())
                {
                    State = AsyncState.Init;
                    tcs.TrySetNngError(res.Err());
                    return;
                }
                State = AsyncState.Init;
                var msg     = Aio.GetMsg();
                var message = Factory.CreateMessage(msg);
                State = AsyncState.Init;
                tcs.TrySetNngResult(message);
                break;

            case AsyncState.Init:
            default:
                tcs.TrySetException(new Exception(State.ToString()));
                break;
            }
        }
Exemple #2
0
        protected override void AioCallback(IntPtr argument)
        {
            var res = Unit.Ok;

            switch (State)
            {
            case AsyncState.Send:
                res = Aio.GetResult();
                if (res.IsErr())
                {
                    HandleFailedSend();
                    State = AsyncState.Init;
                    tcs.TrySetNngError(res.Err());
                    return;
                }
                State = AsyncState.Init;
                tcs.SetNngResult();
                break;

            case AsyncState.Init:
            default:
                tcs.SetException(new Exception(State.ToString()));
                break;
            }
        }
        protected override void AioCallback(IntPtr argument)
        {
            var res = Unit.Ok;

            switch (State)
            {
            case AsyncState.Init:
                init();
                break;

            case AsyncState.Recv:
                res = Aio.GetResult();
                if (res.IsErr())
                {
                    asyncMessage.requestTcs.TrySetNngError(res.Err());
                    State = AsyncState.Recv;
                    return;
                }
                State = AsyncState.Wait;
                nng_msg msg     = Aio.GetMsg();
                var     message = Factory.CreateMessage(msg);
                asyncMessage.requestTcs.SetNngResult(message);
                break;

            case AsyncState.Wait:
                break;

            case AsyncState.Send:
                res = Aio.GetResult();
                if (res.IsErr())
                {
                    HandleFailedSend();
                    asyncMessage.replyTcs.TrySetNngError(res.Err());
                }
                var currentReq = asyncMessage;
                init();
                currentReq.replyTcs.SetNngResult();
                break;
            }
        }
        protected override void AioCallback(IntPtr argument)
        {
            var res = Unit.Ok;

            switch (State)
            {
            case AsyncState.Send:
                res = Aio.GetResult();
                if (res.IsErr())
                {
                    HandleFailedSend();
                    State = AsyncState.Init;
                    sendTcs.TrySetNngError(res.Err());
                    return;
                }
                State = AsyncState.Init;
                sendTcs.TrySetNngResult();
                break;

            case AsyncState.Recv:
                res = Aio.GetResult();
                if (res.IsErr())
                {
                    State = AsyncState.Init;
                    receiveTcs.TrySetNngError(res.Err());
                    return;
                }
                State = AsyncState.Init;
                nng_msg msg     = Aio.GetMsg();
                var     message = Factory.CreateMessage(msg);
                receiveTcs.TrySetNngResult(message);
                break;

            case AsyncState.Init:
            default:
                Console.Error.WriteLine("SendReceive::AioCallback: " + State);
                State = AsyncState.Init;
                break;
            }
        }