public static INodeEndpointProtocolServer WaitForServer <T>( this INodeEndpointProtocolServerListener serverListener, string address, IDuplexNodeEndpoint <T> endpoint, int timeout = DefaultTimeout ) where T : INodeEndpointClient { INodeEndpointProtocolServer server = WaitForServerBase(serverListener, address, endpoint, timeout); if (server != null) { if (server.EnableDuplex) { INodeEndpointClientProvider provider = new ProtocolEnabledClientProvider(); provider.Protocol = server; T endpointInterface = StrongTypedNodeEndpointClientBuilder.Create <T>(provider); endpoint.Callback = endpointInterface; } else { server.Disconnect(); throw new InvalidOperationException("The protocol does not support duplex communication."); } server.BeginListen(); } return(server); }
public static T WaitForClient <T>( this INodeEndpointProtocolFactory protocolFactory, string address, string endpointName, int timeout = DefaultTimeout ) where T : INodeEndpointClient { INodeEndpointProtocolClient client = protocolFactory.CreateClient(); if (client.Connect(address, endpointName, timeout)) { INodeEndpointClientProvider provider = new ProtocolEnabledClientProvider(); provider.Protocol = client; T endpointInterface = StrongTypedNodeEndpointClientBuilder.Create <T>(provider); client.BeginListen(); return(endpointInterface); } else { return(default(T)); } }