示例#1
0
        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);
            }
        }
示例#2
0
 public ProtoClient(IPAddress address, int port, ProtoClientConfiguration configuration)
     : this(configuration, CreateClient(address, port), address.ToString())
 {
 }
示例#3
0
 public ProtoClient(string hostname, int port, ProtoClientConfiguration configuration)
     : this(configuration, CreateClient(hostname, port), hostname)
 {
 }
示例#4
0
 public ProtoClient(IPEndPoint remoteEndPoint, ProtoClientConfiguration configuration)
     : this(configuration, CreateClient(remoteEndPoint), remoteEndPoint.Address.ToString())
 {
 }