public StreamStuff(IAPIFactory <INngMsg> factory) { var url = UrlIpc(); laio = factory.CreateAio().Unwrap(); daio = factory.CreateAio().Unwrap(); listener = factory.StreamListenerCreate(url).Unwrap(); dialer = factory.StreamDialerCreate(url).Unwrap(); laio.SetTimeout(Util.DelayShortMs); daio.SetTimeout(Util.DelayShortMs); listener.Listen().Unwrap(); listener.Accept(laio); dialer.Dial(daio); laio.Wait(); daio.Wait(); // Connected nng_stream is stored as aio output 0 and shouldn't be NULL Assert.NotEqual(IntPtr.Zero, laio.GetOutput(0)); Assert.NotEqual(IntPtr.Zero, daio.GetOutput(0)); lstream = factory.StreamFrom(laio).Unwrap(); dstream = factory.StreamFrom(daio).Unwrap(); }
public static NngResult <INngStream> From(INngAio aio) { var ptr = aio.GetOutput(0); if (ptr == IntPtr.Zero) { return(NngResult <INngStream> .Fail(-1)); } else { var stream = new Stream { stream = new nng_stream(ptr) }; return(NngResult <INngStream> .Ok(stream)); } }