public TcpWorker(IServiceProvider provider, MessagePipeInterprocessTcpOptions options, IAsyncPublisher <IInterprocessKey, IInterprocessValue> publisher) { this.provider = provider; this.cancellationTokenSource = new CancellationTokenSource(); this.options = options; this.publisher = publisher; this.server = new Lazy <SocketTcpServer>(() => { return(SocketTcpServer.Listen(options.Host, options.Port)); }); this.client = new Lazy <SocketTcpClient>(() => { return(SocketTcpClient.Connect(options.Host, options.Port)); }); #if !UNITY_2018_3_OR_NEWER this.channel = Channel.CreateUnbounded <byte[]>(new UnboundedChannelOptions() { SingleReader = true, SingleWriter = false, AllowSynchronousContinuations = true }); #else this.channel = Channel.CreateSingleConsumerUnbounded <byte[]>(); #endif if (options.HostAsServer != null && options.HostAsServer.Value) { StartReceiver(); } }