public static NngResult <IRepReqAsyncContext <T> > Create(IMessageFactory <T> factory, IRepSocket socket) { var context = new RepAsyncCtx <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(); // Start receive loop context.AioCallback(IntPtr.Zero); return(NngResult <IRepReqAsyncContext <T> > .Ok(context)); } return(NngResult <IRepReqAsyncContext <T> > .Err(ctx.Err())); } else { return(NngResult <IRepReqAsyncContext <T> > .Fail(res.Err())); } }
public static NngResult <ISubAsyncContext <T> > Create(IMessageFactory <T> factory, ISubSocket socket) { var context = new SubAsyncCtx <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 <ISubAsyncContext <T> > .Ok(context)); } return(NngResult <ISubAsyncContext <T> > .Err(ctx.Err())); } else { return(NngResult <ISubAsyncContext <T> > .Fail(res.Err())); } }