public static NngResult <ISendReceiveAsyncContext <T> > Create(IMessageFactory <T> factory, ISendRecvSocket socket)
        {
            var context = new SendReceiveAsyncContext <T> {
                Factory = factory, socket = socket
            };
            var res = context.InitAio();

            return(res.Into <ISendReceiveAsyncContext <T> >(context));
        }
Esempio n. 2
0
 public NngResult <ISurveyorAsyncContext <INngMsg> > CreateSurveyorAsyncContext(ISendRecvSocket socket)
 {
     return(SurveyAsyncContext <INngMsg> .Create(this, socket));
 }
Esempio n. 3
0
        public static NngResult <ISurveyorAsyncContext <T> > Create(IMessageFactory <T> factory, ISendRecvSocket socket)
        {
            var context = new SurveyAsyncContext <T> {
                Factory = factory, socket = socket
            };
            var res = context.InitAio();

            if (res.IsOk())
            {
                //TODO: when get default interface methods in C#8 move this to ICtx
                var ctx = NngCtx.Create(socket);
                if (ctx.IsOk())
                {
                    context.Ctx = ctx.Ok();
                    return(NngResult <ISurveyorAsyncContext <T> > .Ok(context));
                }
                return(NngResult <ISurveyorAsyncContext <T> > .Err(ctx.Err()));
            }
            else
            {
                return(NngResult <ISurveyorAsyncContext <T> > .Fail(res.Err()));
            }
        }
Esempio n. 4
0
        public NngResult <ISendReceiveAsyncContext <INngMsg> > CreateSendReceiveAsyncContext(ISendRecvSocket socket, SendReceiveContextSubtype subtype)
        {
            switch (subtype)
            {
            case SendReceiveContextSubtype.Bus:
            case SendReceiveContextSubtype.Pair:
                return(SendReceiveAsyncContext <INngMsg> .Create(this, socket));

            default:
                return(NngResult <ISendReceiveAsyncContext <INngMsg> > .Err(NngErrno.EINVAL));
            }
        }