Ejemplo n.º 1
0
        private void Initialize(IDictionary properties, IServerChannelSinkProvider sinkProvider)
        {
            if (properties != null)
            {
                // read property values
                foreach (DictionaryEntry property in properties)
                {
                    switch ((string)property.Key)
                    {
                    case "name": _channelName = Convert.ToString(property.Value); break;

                    case "priority": _channelPriority = Convert.ToInt32(property.Value); break;

                    case "pipe": _pipe = Convert.ToString(property.Value); break;

                    case "securityDescriptor": _securityDescriptor = (property.Value as SecurityDescriptor); break;
                    }
                }
            }

            // setup pipe name
            _pipeName = new PipeName(@"\\.\pipe\" + _pipe);

            // create the chain of the sink providers that will process all messages
            _sinkProvider = ChannelHelper.ServerChannelCreateSinkProviderChain(sinkProvider);
            _channelData  = ChannelHelper.ServerChannelCreateDataStore(ChannelUri, _sinkProvider);

            // create transport sink
            IServerChannelSink nextSink = ChannelServices.CreateServerChannelSinkChain(_sinkProvider, this);

            _transportSink = new ServerTransportSink(nextSink);

            // create listener thread
            _transportListener           = new TransportListener(ChannelUri, typeof(PipeTransport));
            _listenerThread              = new Thread(new ThreadStart(ListenerStart));
            _listenerThread.IsBackground = true;

            _requestHandler = new ProcessRequestCallback(_transportSink.ProcessRequest);

            // start listening on the channel
            StartListening(null);
        }
Ejemplo n.º 2
0
		private void Initialize(IDictionary properties, IServerChannelSinkProvider sinkProvider)
		{
			if (properties != null)
			{
				// read property values
				foreach (DictionaryEntry property in properties)
				{
					switch ((string)property.Key)
					{
						case "name": _channelName = Convert.ToString(property.Value); break;
						case "priority": _channelPriority = Convert.ToInt32(property.Value); break;
						case "port": _port = Convert.ToInt32(property.Value); break;
						case "bindTo": _bindToAddr = IPAddress.Parse(Convert.ToString(property.Value)); break;
						case "machineName": _machineName = Convert.ToString(property.Value); break;
						case "useIpAddress": _useIpAddress = Convert.ToBoolean(property.Value); break;
						case "rejectRemoteRequests": if (Convert.ToBoolean(property.Value)) _bindToAddr = IPAddress.Loopback; break;
					}
				}
			}

			if (_machineName == null)
			{
				// setup machine name
				if (_useIpAddress)
				{
					if (_bindToAddr == IPAddress.Any)
						_machineName = NetHelper.GetMachineIp();
					else
						_machineName = _bindToAddr.ToString();
				}
				else
				{
					_machineName = NetHelper.GetMachineName();
				}
			}

			// create the chain of the sink providers that will process all messages
			_sinkProvider = ChannelHelper.ServerChannelCreateSinkProviderChain(sinkProvider);
			_channelData = ChannelHelper.ServerChannelCreateDataStore(ChannelUri, _sinkProvider);

			// create transport sink
			IServerChannelSink nextSink = ChannelServices.CreateServerChannelSinkChain(_sinkProvider, this);
			_transportSink = new ServerTransportSink(nextSink);

			// create listener thread
			_transportListener = new TransportListener(ListenerUri, typeof(TcpTransport));
			_listenerThread = new Thread(new ThreadStart(ListenerStart));
			_listenerThread.IsBackground = true;

			_requestHandler = new ProcessRequestCallback(_transportSink.ProcessRequest);

			// start listening on the channel
			StartListening(null);
		}
Ejemplo n.º 3
0
        private void Initialize(IDictionary properties, IServerChannelSinkProvider sinkProvider)
        {
            if (properties != null)
            {
                // read property values
                foreach (DictionaryEntry property in properties)
                {
                    switch ((string)property.Key)
                    {
                    case "name": _channelName = Convert.ToString(property.Value); break;

                    case "priority": _channelPriority = Convert.ToInt32(property.Value); break;

                    case "port": _port = Convert.ToInt32(property.Value); break;

                    case "bindTo": _bindToAddr = IPAddress.Parse(Convert.ToString(property.Value)); break;

                    case "machineName": _machineName = Convert.ToString(property.Value); break;

                    case "useIpAddress": _useIpAddress = Convert.ToBoolean(property.Value); break;

                    case "rejectRemoteRequests": if (Convert.ToBoolean(property.Value))
                        {
                            _bindToAddr = IPAddress.Loopback;
                        }
                        break;
                    }
                }
            }

            if (_machineName == null)
            {
                // setup machine name
                if (_useIpAddress)
                {
                    if (_bindToAddr == IPAddress.Any)
                    {
                        _machineName = NetHelper.GetMachineIp();
                    }
                    else
                    {
                        _machineName = _bindToAddr.ToString();
                    }
                }
                else
                {
                    _machineName = NetHelper.GetMachineName();
                }
            }

            // create the chain of the sink providers that will process all messages
            _sinkProvider = ChannelHelper.ServerChannelCreateSinkProviderChain(sinkProvider);
            _channelData  = ChannelHelper.ServerChannelCreateDataStore(ChannelUri, _sinkProvider);

            // create transport sink
            IServerChannelSink nextSink = ChannelServices.CreateServerChannelSinkChain(_sinkProvider, this);

            _transportSink = new ServerTransportSink(nextSink);

            // create listener thread
            _transportListener           = new TransportListener(ListenerUri, typeof(TcpTransport));
            _listenerThread              = new Thread(new ThreadStart(ListenerStart));
            _listenerThread.IsBackground = true;

            _requestHandler = new ProcessRequestCallback(_transportSink.ProcessRequest);

            // start listening on the channel
            StartListening(null);
        }
Ejemplo n.º 4
0
		private void Initialize(IDictionary properties, IServerChannelSinkProvider sinkProvider)
		{
			if (properties != null)
			{
				// read property values
				foreach (DictionaryEntry property in properties)
				{
					switch ((string)property.Key)
					{
						case "name": _channelName = Convert.ToString(property.Value); break;
						case "priority": _channelPriority = Convert.ToInt32(property.Value); break;
						case "pipe": _pipe = Convert.ToString(property.Value); break;
						case "securityDescriptor": _securityDescriptor = (property.Value as SecurityDescriptor); break;
					}
				}
			}

			// setup pipe name
			_pipeName = new PipeName(@"\\.\pipe\" + _pipe);

			// create the chain of the sink providers that will process all messages
			_sinkProvider = ChannelHelper.ServerChannelCreateSinkProviderChain(sinkProvider);
			_channelData = ChannelHelper.ServerChannelCreateDataStore(ChannelUri, _sinkProvider);

			// create transport sink
			IServerChannelSink nextSink = ChannelServices.CreateServerChannelSinkChain(_sinkProvider, this);
			_transportSink = new ServerTransportSink(nextSink);

			// create listener thread
			_transportListener = new TransportListener(ChannelUri, typeof(PipeTransport));
			_listenerThread = new Thread(new ThreadStart(ListenerStart));
			_listenerThread.IsBackground = true;

			_requestHandler = new ProcessRequestCallback(_transportSink.ProcessRequest);

			// start listening on the channel
			StartListening(null);
		}