示例#1
0
        /// <summary>
        /// Creates the server side of the current duplex channel.
        /// </summary>
        /// <remarks>
        /// In general, this method must always be called before calling <see cref="CreateClient"/>.
        /// </remarks>
        private void CreateServer()
        {
            var provider = new BinaryServerFormatterSinkProvider {
                TypeFilterLevel = TypeFilterLevel.Full
            };
            var securityDescriptor = CreateSecurityDescriptor(_localEndPointConfig.AllowedClients);

            _serverChannel = new IpcServerChannel(_localChannelProperties.AsDictionary(), provider, securityDescriptor);
            ChannelServices.RegisterChannel(_serverChannel, false);
            RemotingConfiguration.RegisterWellKnownServiceType(_localEndPointConfig.RemoteObjectType,
                                                               _localChannelProperties.EndPointName,
                                                               _localEndPointConfig.ObjectMode);
            _state |= DuplexChannelState.ServerUp;
        }
示例#2
0
 /// <summary>
 /// Tries to connect as a client in the current duplex channel.
 /// <see cref="_state"/> is set accordingly.
 /// </summary>
 /// <returns></returns>
 private bool TryConnectClient()
 {
     try
     {
         var remoteEndPoint = GetRemoteEndPoint(false);
         remoteEndPoint.SignalEndpointReady();
         _state |= DuplexChannelState.ClientUp;
         return(true);
     }
     catch (RemotingException)
     {
         return(false);
     }
 }
示例#3
0
        /// <summary>
        /// Tries to connect as a client in the current duplex channel.
        /// <see cref="_state"/> is set accordingly.
        /// </summary>
        /// <returns></returns>
        private bool TryConnectClient()
        {
            try
            {
                var remoteEndPoint = GetRemoteEndPoint(false);
#pragma warning disable 618
                remoteEndPoint.SignalEndpointReady();
#pragma warning restore 618
                _state |= DuplexChannelState.ClientUp;
                return(true);
            }
            catch (RemotingException)
            {
                return(false);
            }
        }