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)); }
public NngResult <ISurveyorAsyncContext <INngMsg> > CreateSurveyorAsyncContext(ISendRecvSocket socket) { return(SurveyAsyncContext <INngMsg> .Create(this, socket)); }
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())); } }
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)); } }