private ProtoClient(ProtoClientConfiguration configuration, TcpClient tcpClient, string hostname)
        {
            Require.NotNull(hostname, "hostname");

            Configuration = configuration ?? new ProtoClientConfiguration();
            Configuration.Freeze();

            ServiceAssembly = ServiceRegistry.GetAssemblyRegistration(
                Configuration.ServiceAssembly ?? GetType().Assembly
            );

            var streamManager = Configuration.StreamManager ?? new MemoryStreamManager();

            _connection = new ClientConnection(this, tcpClient, hostname, streamManager);

            if (Configuration.CallbackObject != null)
            {
                Service service = null;

                if (!(Configuration.CallbackObject is IProtoMessageDispatcher))
                    service = ServiceAssembly.GetServiceRegistration(Configuration.CallbackObject.GetType());

                _connection.Client = new Client(configuration.CallbackObject, ServiceAssembly, service);
            }
        }
 public ProtoClient(IPAddress address, int port, ProtoClientConfiguration configuration)
     : this(configuration, CreateClient(address, port), address.ToString())
 {
 }
 public ProtoClient(string hostname, int port, ProtoClientConfiguration configuration)
     : this(configuration, CreateClient(hostname, port), hostname)
 {
 }
 public ProtoClient(IPEndPoint remoteEndPoint, ProtoClientConfiguration configuration)
     : this(configuration, CreateClient(remoteEndPoint), remoteEndPoint.Address.ToString())
 {
 }