public void Start(ProcessRequestCallback processRequestCallback, ConnectionClosedCallback connectionClosedCallback) { _processRequestCallback = processRequestCallback; _connectionClosedCallback = connectionClosedCallback; _receiveLoopTask = ReceiveLoopAsync(_receiveLoopCancellationTokenSource.Token); var _ = _receiveLoopTask.ContinueWith(t => ReceiveLoopFaulted(t.Exception), default,
public void AddConnection(IConnection connection, ProcessRequestCallback requestHandler) { // parameters validation if (connection == null) throw new ArgumentNullException("connection"); if (requestHandler == null) throw new ArgumentNullException("requestHandler"); // wait for requests on this connection BeginWaitForRequest(new QueuedRequest(connection, requestHandler)); }
public void AddConnection(IConnection connection, ProcessRequestCallback requestHandler) { // parameters validation if (connection == null) { throw new ArgumentNullException("connection"); } if (requestHandler == null) { throw new ArgumentNullException("requestHandler"); } // wait for requests on this connection BeginWaitForRequest(new QueuedRequest(connection, requestHandler)); }
public static bool RegisterHandler(uint MessageFlag, uint MessageItem, ProcessRequestCallback Callback, bool PermitedUnauthenticated = false) { if (Callback == null) { return(false); } if (dictionary_0.ContainsKey(new KeyValuePair <uint, uint>(MessageFlag, MessageItem))) { return(false); } dictionary_0.Add(new KeyValuePair <uint, uint>(MessageFlag, MessageItem), Callback); if (PermitedUnauthenticated) { list_0.Add(new KeyValuePair <uint, uint>(MessageFlag, MessageItem)); } return(true); }
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); }
public static bool RegisterHandler(uint MessageId, ProcessRequestCallback Callback, bool PermitedUnauthenticated = false) { if (MessageId < 0 || Callback == null) { return false; } if (mCallbacks.ContainsKey(MessageId)) { return false; } mCallbacks.Add(MessageId, Callback); if (PermitedUnauthenticated) { mCallbacksWithoutAuthentication.Add(MessageId); } return true; }
public static bool RegisterHandler(uint MessageId, ProcessRequestCallback Callback, bool PermitedUnauthenticated = false) { if (MessageId < 0 || Callback == null) { return(false); } if (mCallbacks.ContainsKey(MessageId)) { return(false); } mCallbacks.Add(MessageId, Callback); if (PermitedUnauthenticated) { mCallbacksWithoutAuthentication.Add(MessageId); } return(true); }
public QueuedRequest(IConnection connection, ProcessRequestCallback requestHandler) { _connection = connection; _requestHandler = requestHandler; }
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); }
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); }
/// <summary> /// Checks the request modified meta and ensures is added to response. /// </summary> /// <param name="context">The context.</param> /// <param name="fileName">Name of the file.</param> /// <param name="modifiedDate">The modified date.</param> /// <param name="callback">The callback.</param> public static void CheckRequestModified(this HttpContext context, string fileName, DateTime modifiedDate, ProcessRequestCallback callback) { if (!context.Request.IsFileModified(fileName, modifiedDate)) { context.Response.ReturnNotModified(fileName, DateTime.Now); } else { context.Response.AppendModifiedMeta(fileName, DateTime.Now); callback(context); } }