/// <summary>
        /// Constructs an instance of the SharedMemoryConnectionManager class.
        /// </summary>
        /// <param name="iTransportContext">The transport context.</param>
        public SharedMemoryConnectionManager(ITransportContext iTransportContext) : base(iTransportContext)
        {
            this._sendTimeoutSpan = GenuineUtility.ConvertToMilliseconds(iTransportContext.IParameterProvider[GenuineParameter.SMSendTimeout]);

            this.Local = new HostInformation("_gshmem://" + iTransportContext.HostIdentifier, iTransportContext);
            TimerProvider.Attach(this);
        }
Beispiel #2
0
 /// <summary>
 /// Constructs an instance of the UdpConnectionManager class.
 /// </summary>
 /// <param name="iTransportContext">The transport context.</param>
 public UdpConnectionManager(ITransportContext iTransportContext) : base(iTransportContext)
 {
     this.Local       = new HostInformation("_gudp://" + iTransportContext.HostIdentifier, iTransportContext);
     this._sendBuffer = new byte[(int)iTransportContext.IParameterProvider[GenuineParameter.UdpPacketSize]];
     TimerProvider.Attach(this);
     this._closeInvocationConnectionAfterInactivity = GenuineUtility.ConvertToMilliseconds(iTransportContext.IParameterProvider[GenuineParameter.CloseInvocationConnectionAfterInactivity]);
 }
Beispiel #3
0
        /// <summary>
        /// Makes message up from the IMessage.
        /// </summary>
        /// <param name="iTransportContext">The Transport Context.</param>
        /// <param name="iMessage">IMessage to make the message up from.</param>
        /// <param name="iTransportHeaders">Trasport headers.</param>
        /// <param name="stream">Message body.</param>
        /// <param name="isSynchronous">True if the invocation is synchronous.</param>
        /// <returns>An instance of the Message class.</returns>
        public static Message CreateOutcomingMessage(ITransportContext iTransportContext, IMessage iMessage, ITransportHeaders iTransportHeaders, Stream stream, bool isSynchronous)
        {
            // when microsoft guys start caring about detailed .NET remoting documentation???
            string url = (string)iMessage.Properties["__Uri"];
            string objectURI;

            string channelUri = GenuineUtility.Parse(url, out objectURI);

            if (objectURI == null)
            {
                objectURI = url;                        // not well-known object
            }
            iTransportHeaders[TransportHeaderName_RemoteObjectUri] = objectURI;
            Message message = new Message(iTransportContext, null, 0, iTransportHeaders, stream);

            message.IMessage      = iMessage;
            message.IsSynchronous = isSynchronous;

            if (iTransportHeaders[Message.TransportHeadersGenuineMessageType] != null)
            {
                message.GenuineMessageType = (GenuineMessageType)iTransportHeaders[Message.TransportHeadersGenuineMessageType];
            }

            return(message);
        }
Beispiel #4
0
 /// <summary>
 /// Constructs an instance of the SMAcceptConnectionClosure class.
 /// </summary>
 /// <param name="iTransportContext">The transport context.</param>
 /// <param name="sharedMemoryConnection">The server's connection.</param>
 /// <param name="sharedMemoryConnectionManager">The connection manager.</param>
 /// <param name="shareName">The name of the share.</param>
 public SMAcceptConnectionClosure(ITransportContext iTransportContext, SharedMemoryConnection sharedMemoryConnection, SharedMemoryConnectionManager sharedMemoryConnectionManager, string shareName)
 {
     this.ITransportContext             = iTransportContext;
     this.SharedMemoryConnection        = sharedMemoryConnection;
     this.SharedMemoryConnectionManager = sharedMemoryConnectionManager;
     this.ShareName = shareName;
 }
 /// <summary>
 /// Constructs an instance of the SMAcceptConnectionClosure class.
 /// </summary>
 /// <param name="iTransportContext">The transport context.</param>
 /// <param name="sharedMemoryConnection">The server's connection.</param>
 /// <param name="sharedMemoryConnectionManager">The connection manager.</param>
 /// <param name="shareName">The name of the share.</param>
 public SMAcceptConnectionClosure(ITransportContext iTransportContext, SharedMemoryConnection sharedMemoryConnection, SharedMemoryConnectionManager sharedMemoryConnectionManager, string shareName)
 {
     this.ITransportContext = iTransportContext;
     this.SharedMemoryConnection = sharedMemoryConnection;
     this.SharedMemoryConnectionManager = sharedMemoryConnectionManager;
     this.ShareName = shareName;
 }
 /// <summary>
 /// Constructs an instance of the AcceptConnectionClosure class.
 /// </summary>
 /// <param name="iTransportContext">The transport context.</param>
 /// <param name="listeningEndPoint">The end point.</param>
 /// <param name="socket">The socket.</param>
 /// <param name="iAcceptConnectionConsumer"></param>
 public AcceptConnectionClosure(ITransportContext iTransportContext, string listeningEndPoint, Socket socket, IAcceptConnectionConsumer iAcceptConnectionConsumer)
 {
     this.ITransportContext = iTransportContext;
     this.ListeningEndPoint = listeningEndPoint;
     this.Socket = socket;
     this.IAcceptConnectionConsumer = iAcceptConnectionConsumer;
 }
 /// <summary>
 /// Constructs an instance of the AcceptConnectionClosure class.
 /// </summary>
 /// <param name="iTransportContext">The transport context.</param>
 /// <param name="listeningEndPoint">The end point.</param>
 /// <param name="socket">The socket.</param>
 /// <param name="iAcceptConnectionConsumer"></param>
 public AcceptConnectionClosure(ITransportContext iTransportContext, string listeningEndPoint, Socket socket, IAcceptConnectionConsumer iAcceptConnectionConsumer)
 {
     this.ITransportContext         = iTransportContext;
     this.ListeningEndPoint         = listeningEndPoint;
     this.Socket                    = socket;
     this.IAcceptConnectionConsumer = iAcceptConnectionConsumer;
 }
        /// <summary>
        /// Constructs an instance of the SharedMemoryConnectionManager class.
        /// </summary>
        /// <param name="iTransportContext">The transport context.</param>
        public SharedMemoryConnectionManager(ITransportContext iTransportContext)
            : base(iTransportContext)
        {
            this._sendTimeoutSpan = GenuineUtility.ConvertToMilliseconds(iTransportContext.IParameterProvider[GenuineParameter.SMSendTimeout]);

            this.Local = new HostInformation("_gshmem://" + iTransportContext.HostIdentifier, iTransportContext);
            TimerProvider.Attach(this);
        }
 /// <summary>
 /// Constructs an instance of the UdpConnectionManager class.
 /// </summary>
 /// <param name="iTransportContext">The transport context.</param>
 public UdpConnectionManager(ITransportContext iTransportContext)
     : base(iTransportContext)
 {
     this.Local = new HostInformation("_gudp://" + iTransportContext.HostIdentifier, iTransportContext);
     this._sendBuffer = new byte[(int) iTransportContext.IParameterProvider[GenuineParameter.UdpPacketSize]];
     TimerProvider.Attach(this);
     this._closeInvocationConnectionAfterInactivity = GenuineUtility.ConvertToMilliseconds(iTransportContext.IParameterProvider[GenuineParameter.CloseInvocationConnectionAfterInactivity]);
 }
 public AmqpConnection(AmqpProvider provider, ITransportContext transport, ConnectionInfo info)
 {
     this.Provider       = provider;
     this.transport      = transport;
     this.remoteUri      = provider.RemoteUri;
     this.Info           = info;
     this.messageFactory = new AmqpMessageFactory(this);
 }
Beispiel #11
0
        /// <summary>
        /// Constructs an instance of the MessageContainer class.
        /// </summary>
        public MessageContainer(ITransportContext iTransportContext)
        {
            this._iTransportContext = iTransportContext;

            this._maxQueuedItems = (int)iTransportContext.IParameterProvider[GenuineParameter.MaxQueuedItems];
            this._maxTotalSize   = (int)iTransportContext.IParameterProvider[GenuineParameter.MaxTotalSize];
            this._maxContentSize = (int)iTransportContext.IParameterProvider[GenuineParameter.MaxContentSize];
            this._noSizeChecking = (bool)iTransportContext.IParameterProvider[GenuineParameter.NoSizeChecking];
        }
Beispiel #12
0
        public IProvider CreateProvider(Uri remoteUri)
        {
            ITransportContext transportContext = TransportContextFactory.CreateTransportContext(remoteUri);
            AmqpProvider amqpProvider = new AmqpProvider(remoteUri, transportContext);

            StringDictionary properties = URISupport.ParseQuery(remoteUri.Query);
            StringDictionary filteredProperties = PropertyUtil.FilterProperties(properties, "amqp.");
            PropertyUtil.SetProperties(amqpProvider, filteredProperties);

            return amqpProvider;
        }
        /// <summary>
        /// Constructs an instance of the HostInformation class.
        /// Instances of the class HostInformation must be constructed only by objects implementing 
        /// the IKnownHosts interface.
        /// </summary>
        /// <param name="uriOrUrl">Uri or Url of the remote host.</param>
        /// <param name="iTransportContext">Transport Context.</param>
        internal HostInformation(string uriOrUrl, ITransportContext iTransportContext)
        {
            this._iTransportContext = iTransportContext;

            if (uriOrUrl[0] == '_')
            {
                this._uri = uriOrUrl;
                UriStorage.RegisterConnection(uriOrUrl, this.ITransportContext);
            }
            else
                this._url = uriOrUrl;
        }
        public static ITransportContext CreateTransportContext(Uri uri)
        {
            ITransportContext transportContext = uri.Scheme.ToUpper().Equals("AMQPS")
                ? new SecureTransportContext()
                : new TransportContext();

            StringDictionary properties         = URISupport.ParseQuery(uri.Query);
            StringDictionary filteredProperties = PropertyUtil.FilterProperties(properties, "transport.");

            PropertyUtil.SetProperties(transportContext, filteredProperties);

            return(transportContext);
        }
Beispiel #15
0
        /// <summary>
        /// Gets a Transport Context responsible for the connection to the specified remoteUri.
        /// </summary>
        /// <param name="remoteUri">The uri of the remote host.</param>
        /// <returns>Transport Context or a null reference.</returns>
        public static ITransportContext GetTransportContext(string remoteUri)
        {
            ITransportContext iTransportContext = null;

            WeakReference weakReference = _knownUris[remoteUri] as WeakReference;

            if (weakReference != null)
            {
                iTransportContext = weakReference.Target as ITransportContext;
            }

            return(iTransportContext);
        }
Beispiel #16
0
        /// <summary>
        /// Constructs the instance of the LabelledStream class.
        /// </summary>
        /// <param name="iTransportContext">The transport context.</param>
        /// <param name="underlyingStream">The source stream containing labelled content.</param>
        /// <param name="intermediateBuffer">The intermediate buffer.</param>
        public LabelledStream(ITransportContext iTransportContext, Stream underlyingStream, byte[] intermediateBuffer)
        {
            this.ITransportContext = iTransportContext;
            this._underlyingStream = underlyingStream;

            this._readBuffer = intermediateBuffer;

            this._validLength            = 0;
            this._currentPosition        = 0;
            this._currentPacketSize      = 0;
            this._currentPacketBytesRead = 0;
            this._messageRead            = false;
        }
Beispiel #17
0
        /// <summary>
        /// Constructs an instance of the TcpSocketInfo class.
        /// </summary>
        /// <param name="socket">The socket.</param>
        /// <param name="iTransportContext">Transport Context.</param>
        /// <param name="connectionName">The name of the connection.</param>
        internal TcpSocketInfo(Socket socket, ITransportContext iTransportContext, string connectionName)
#endif
        {
            this.Socket            = socket;
            this.ITransportContext = iTransportContext;
            this.ConnectionName    = connectionName == null ? "~" + Guid.NewGuid().ToString("N") : connectionName;
            this.MaxSendSize       = (int)this.ITransportContext.IParameterProvider[GenuineParameter.TcpMaxSendSize];

#if DEBUG
            this._typeOfSocket     = typeOfSocket;
            this._connectionNumber = Interlocked.Increment(ref _dbg_ConnectionCounter);
#endif
        }
        /// <summary>
        /// Constructs an instance of the GenuineTcpClientTransportSink class.
        /// </summary>
        /// <param name="url">The Url of the remote object.</param>
        /// <param name="iTransportContext">The transport context.</param>
        public GenuineTcpClientTransportSink(string url, ITransportContext iTransportContext)
        {
            this.ITransportContext = iTransportContext;

            string objectURI;
            this._recipientUri = GenuineUtility.Parse(url, out objectURI);

            this._properties["GC_URI"] = this._recipientUri;
            this._properties["GC_TC"] = iTransportContext;

            // it's rather a trick, but works well
            this._properties["GC_TS"] = this;
        }
Beispiel #19
0
        /// <summary>
        /// Constructs an instance of the HttpServerConnection class.
        /// </summary>
        /// <param name="iTransportContext">The Transport Context.</param>
        /// <param name="hostId">The id of the remote host.</param>
        /// <param name="remote">The remote host.</param>
        /// <param name="connectionName">The name of the connection.</param>
        /// <param name="closeConnectionAfterInactivity">The time span to renew a connection after each message.</param>
        public HttpServerConnection(ITransportContext iTransportContext, Guid hostId, HostInformation remote, string connectionName, int closeConnectionAfterInactivity)
        {
            this.ITransportContext           = iTransportContext;
            this.HttpServerConnectionManager = (HttpServerConnectionManager)iTransportContext.ConnectionManager;
            this.ConnectionName = connectionName;
            this.CloseConnectionAfterInactivity = closeConnectionAfterInactivity;

            this.HostId                    = hostId.ToByteArray();
            this.HostIdAsString            = hostId.ToString("N");
            this.Listener_MessageContainer = new MessageContainer(iTransportContext);

            this.Remote = remote;
        }
        public void TestCreateWithDefaultOptions()
        {
            Uri uri = new Uri("amqp://localhost:5672");
            ITransportContext transportContext = TransportContextFactory.CreateTransportContext(uri);

            Assert.NotNull(transportContext);
            Assert.IsFalse(transportContext.IsSecure);

            Assert.AreEqual(8192, transportContext.ReceiveBufferSize);
            Assert.AreEqual(0, transportContext.ReceiveTimeout);
            Assert.AreEqual(8192, transportContext.SendBufferSize);
            Assert.AreEqual(0, transportContext.SendTimeout);
            Assert.IsTrue(transportContext.TcpNoDelay);
        }
Beispiel #21
0
        /// <summary>
        /// Constructs an instance of the HostInformation class.
        /// Instances of the class HostInformation must be constructed only by objects implementing
        /// the IKnownHosts interface.
        /// </summary>
        /// <param name="uriOrUrl">Uri or Url of the remote host.</param>
        /// <param name="iTransportContext">Transport Context.</param>
        internal HostInformation(string uriOrUrl, ITransportContext iTransportContext)
        {
            this._iTransportContext = iTransportContext;

            if (uriOrUrl[0] == '_')
            {
                this._uri = uriOrUrl;
                UriStorage.RegisterConnection(uriOrUrl, this.ITransportContext);
            }
            else
            {
                this._url = uriOrUrl;
            }
        }
        /// <summary>
        /// Constructs an instance of the GenuineTcpClientTransportSink class.
        /// </summary>
        /// <param name="url">The Url of the remote object.</param>
        /// <param name="iTransportContext">The transport context.</param>
        public GenuineTcpClientTransportSink(string url, ITransportContext iTransportContext)
        {
            this.ITransportContext = iTransportContext;

            string objectURI;

            this._recipientUri = GenuineUtility.Parse(url, out objectURI);

            this._properties["GC_URI"] = this._recipientUri;
            this._properties["GC_TC"]  = iTransportContext;

            // it's rather a trick, but works well
            this._properties["GC_TS"] = this;
        }
        /// <summary>
        /// Constructs an instance of the HttpServerConnectionManager class.
        /// </summary>
        /// <param name="iTransportContext">The transport context.</param>
        public HttpServerConnectionManager(ITransportContext iTransportContext)
            : base(iTransportContext)
        {
            this.Local = new HostInformation("_ghttp://" + iTransportContext.HostIdentifier, iTransportContext);
            this._releaseConnections_InspectPersistentConnections = new PersistentConnectionStorage.ProcessConnectionEventHandler(this.ReleaseConnections_InspectPersistentConnections);
            this._internal_TimerCallback_InspectPersistentConnections = new PersistentConnectionStorage.ProcessConnectionEventHandler(this.Internal_TimerCallback_InspectPersistentConnections);

            // calculate host renewing timespan
            //			this._hostRenewingSpan = GenuineUtility.ConvertToMilliseconds(iTransportContext.IParameterProvider[GenuineParameter.ClosePersistentConnectionAfterInactivity]) + GenuineUtility.ConvertToMilliseconds(iTransportContext.IParameterProvider[GenuineParameter.MaxTimeSpanToReconnect]);
            this._internal_TimerCallback = new WaitCallback(Internal_TimerCallback);

            this._closeInvocationConnectionAfterInactivity = GenuineUtility.ConvertToMilliseconds(this.ITransportContext.IParameterProvider[GenuineParameter.CloseInvocationConnectionAfterInactivity]);

            TimerProvider.Attach(this);
        }
 public TransportAction(
     string id,
     ITransportContext ctx,
     DbCommand cmdSrc,
     DbCommand cmdDst
     )
     : base(id, ctx)
 {
     this.CmdSrc   = cmdSrc;
     this.CmdDst   = cmdDst;
     this.Source   = new DbTransportSource(cmdSrc);
     this.Sink     = new DbTransportSink(cmdSrc);
     this.Result   = new TransportActionResult(id, TransportActionResultCode.None);
     this.Handlers = new List <DbDataReaderHandlerBase>();
 }
        /// <summary>
        /// Constructs an instance of the XHttpConnectionManager class.
        /// </summary>
        /// <param name="iTransportContext">The transport context.</param>
        public XHttpConnectionManager(ITransportContext iTransportContext)
            : base(iTransportContext)
        {
            this._HalfSync_Client_onEndReceiving = new AsyncCallback(this.LowLevel_HalfSync_Client_EndReceiving);
            this._HalfSync_Server_onEndReceiving = new AsyncCallback(this.LowLevel_HalfSync_Server_EndReceiving);
            this._AsyncSending_onEndSending = new AsyncCallback(this.LowLevel_OnEndAsyncSending);
            this._internal_TimerCallback = new WaitCallback(this.Internal_TimerCallback);
            this._HalfSync_Client_onContinueReceiving = new WaitCallback(this.Pool_Client_ContinueHalfSyncReceiving);
            this._HalfSync_Server_onContinueReceiving = new WaitCallback(this.Pool_Server_ContinueHalfSyncReceiving);
            this._releaseConnections_InspectPersistentConnections = new PersistentConnectionStorage.ProcessConnectionEventHandler(this.ReleaseConnections_InspectPersistentConnections);
            this._internal_TimerCallback_InspectPersistentConnections = new PersistentConnectionStorage.ProcessConnectionEventHandler(this.Internal_TimerCallback_InspectPersistentConnections);

            this.Local = new HostInformation("_ghttp://" + iTransportContext.HostIdentifier, iTransportContext);
            TimerProvider.Attach(this);

            _xHttpReadHeaderTimeout = GenuineUtility.ConvertToMilliseconds(iTransportContext.IParameterProvider[GenuineParameter.XHttpReadHttpMessageTimeout]);
        }
        /// <summary>
        /// Constructs an instance of the HttpClientConnectionManager class.
        /// </summary>
        /// <param name="iTransportContext">The transport context.</param>
        public HttpClientConnectionManager(ITransportContext iTransportContext)
            : base(iTransportContext)
        {
            this.Local = new HostInformation("_ghttp://" + iTransportContext.HostIdentifier, iTransportContext);

            // calculate host renewing timespan
            this._hostRenewingSpan = GenuineUtility.ConvertToMilliseconds(iTransportContext.IParameterProvider[GenuineParameter.ClosePersistentConnectionAfterInactivity]) + GenuineUtility.ConvertToMilliseconds(iTransportContext.IParameterProvider[GenuineParameter.MaxTimeSpanToReconnect]);
            this._internal_TimerCallback = new WaitCallback(Internal_TimerCallback);

            this._pool_Sender_OnEndSending_ContinueExchange = new WaitCallback(this.Pool_Sender_OnEndSending_ContinueExchange);
            this._listener_OnEndReceiving_ContinueExchange = new WaitCallback(this.Pool_Sender_OnEndSending_ContinueExchange);

            this._webRequestInitiationTimeout = (TimeSpan) iTransportContext.IParameterProvider[GenuineParameter.HttpWebRequestInitiationTimeout];
            this._httpAsynchronousRequestTimeout = GenuineUtility.ConvertToMilliseconds(iTransportContext.IParameterProvider[GenuineParameter.HttpAsynchronousRequestTimeout]);

            TimerProvider.Attach(this);
        }
        public void TestCreateWithCustomOptions()
        {
            Uri uri = new Uri("amqp://localhost:5672" + "?" +
                              "transport.receiveBufferSize=" + customReceiveBufferSize + "&" +
                              "transport.receiveTimeout=" + customReceiveTimeout + "&" +
                              "transport.sendBufferSize=" + customSendBufferSize + "&" +
                              "transport.sendTimeout=" + customSendTimeout + "&" +
                              "transport.tcpNoDelay=" + customTcpNoDelay);
            ITransportContext transportContext = TransportContextFactory.CreateTransportContext(uri);

            Assert.NotNull(transportContext);
            Assert.IsFalse(transportContext.IsSecure);

            Assert.AreEqual(customReceiveBufferSize, transportContext.ReceiveBufferSize);
            Assert.AreEqual(customReceiveTimeout, transportContext.ReceiveTimeout);
            Assert.AreEqual(customSendBufferSize, transportContext.SendBufferSize);
            Assert.AreEqual(customSendTimeout, transportContext.SendTimeout);
            Assert.AreEqual(customTcpNoDelay, transportContext.TcpNoDelay);
        }
Beispiel #28
0
        /// <summary>
        /// Constructs an instance of the Message class.
        /// </summary>
        /// <param name="iTransportContext">The Transport Context.</param>
        /// <param name="recipient">Recipient.</param>
        /// <param name="replyToId">Source id or zero.</param>
        /// <param name="iTransportHeaders">Transport headers.</param>
        /// <param name="stream">Message.</param>
        public Message(ITransportContext iTransportContext, HostInformation recipient, int replyToId, ITransportHeaders iTransportHeaders, Stream stream)
        {
            this.ITransportContext = iTransportContext;
            this.ITransportHeaders = iTransportHeaders;
            this.Recipient         = recipient;
            this.ReplyToId         = replyToId;
            this.Stream            = stream;

            if (this.ITransportHeaders != null)
            {
                this.ITransportHeaders[TransportHeadersSenderEntryName] = this.Sender;
            }

            this.MessageId = Interlocked.Increment(ref _currentMessageId);

#if TRIAL
            if (this.MessageId > 3001)
            {
                throw GenuineExceptions.Get_Channel_TrialConditionExceeded("The maximum number of messages restriction has been exceeded. You can not send more than 3000 messages using TRIAL version.");
            }
#endif
        }
Beispiel #29
0
        /// <summary>
        /// Answers Genuine Channels URI and Transport Context via which access to the remote
        /// MarshalByRefObject object is performed.
        /// </summary>
        /// <param name="marshalByRefObject">MarshalByRefObject instance to fetch the URI from.</param>
        /// <param name="uri">The uri.</param>
        /// <param name="iTransportContext">The transport context.</param>
        public static void FetchChannelUriFromMbr(MarshalByRefObject marshalByRefObject, out string uri, out ITransportContext iTransportContext)
        {
            IDictionary iDictionary = ChannelServices.GetChannelSinkProperties(marshalByRefObject);

            uri = iDictionary["GC_URI"] as string;
            iTransportContext = iDictionary["GC_TC"] as ITransportContext;
        }
 /// <summary>
 /// Constructs an instance of the DirectExchangeManager class.
 /// </summary>
 /// <param name="iTransportContext">The Transport Context.</param>
 public DirectExchangeManager(ITransportContext iTransportContext)
 {
     this.ITransportContext = iTransportContext;
 }
        /// <summary>
        /// Constructs an instance of the HttpServerConnection class.
        /// </summary>
        /// <param name="iTransportContext">The Transport Context.</param>
        /// <param name="hostId">The id of the remote host.</param>
        /// <param name="remote">The remote host.</param>
        /// <param name="connectionName">The name of the connection.</param>
        /// <param name="closeConnectionAfterInactivity">The time span to renew a connection after each message.</param>
        public HttpServerConnection(ITransportContext iTransportContext, Guid hostId, HostInformation remote, string connectionName, int closeConnectionAfterInactivity)
        {
            this.ITransportContext = iTransportContext;
            this.HttpServerConnectionManager = (HttpServerConnectionManager) iTransportContext.ConnectionManager;
            this.ConnectionName = connectionName;
            this.CloseConnectionAfterInactivity = closeConnectionAfterInactivity;

            this.HostId = hostId.ToByteArray();
            this.HostIdAsString = hostId.ToString("N");
            this.Listener_MessageContainer = new MessageContainer(iTransportContext);

            this.Remote = remote;
        }
 public InformationService(ITransportContext context)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
 }
 /// <summary>
 /// Initializes an instance of the AsyncSinkStackResponseProcessor class.
 /// </summary>
 /// <param name="iTransportContext">The Transport Context.</param>
 /// <param name="message">Source message.</param>
 /// <param name="iClientChannelSinkStack">The client channel sink stack.</param>
 public AsyncSinkStackResponseProcessor(ITransportContext iTransportContext, Message message, IClientChannelSinkStack iClientChannelSinkStack)
 {
     this._iTransportContext = iTransportContext;
     this._message = message;
     this._iClientChannelSinkStack = iClientChannelSinkStack;
 }
        /// <summary>
        /// Constructs an instance of the HttpInvocationConnection class.
        /// </summary>
        /// <param name="iTransportContext">The transport context.</param>
        /// <param name="remote">The remote host.</param>
        public HttpInvocationConnection(ITransportContext iTransportContext, HostInformation remote)
        {
            this.HostId         = iTransportContext.BinaryHostIdentifier;
            this.HostIdAsString = iTransportContext.HostIdentifier;
            this._asyncCallback_onRequestCompleted = new AsyncCallback(this.OnRequestCompleted);

            this.ITransportContext = iTransportContext;
            this.Remote            = remote;

//			this.OnEndSending = new AsyncCallback(this.Callback_OnEndSending);
//			this.OnEndReceiving = new AsyncCallback(this.Callback_OnEndReceiving);

            // cache all setting's values
            this._userAgent = this.ITransportContext.IParameterProvider[GenuineParameter.HttpWebUserAgent] as string;
            if (this._userAgent == null)
            {
                this._userAgent = @"Mozilla/4.0+ (compatible; MSIE 6.0; Windows " + Environment.OSVersion.Version +
                                  "; Genuine HTTP Client Channel; MS .NET CLR " + Environment.Version.ToString() + ")";
            }
            this._userAgent = Regex.Replace(this._userAgent, "\r|\n", " ", RegexOptions.None);

            this._useUnsafeConnectionSharing = (bool)this.ITransportContext.IParameterProvider[GenuineParameter.HttpUnsafeConnectionSharing];
            this._allowWriteStreamBuffering  = (bool)this.ITransportContext.IParameterProvider[GenuineParameter.HttpAllowWriteStreamBuffering];

            this._keepalive   = (bool)iTransportContext.IParameterProvider[GenuineParameter.HttpKeepAlive];
            this._credentials = this.ITransportContext.IParameterProvider[GenuineParameter.HttpAuthCredential] as ICredentials;
            string userName = this.ITransportContext.IParameterProvider[GenuineParameter.HttpAuthUserName] as string;
            string password = this.ITransportContext.IParameterProvider[GenuineParameter.HttpAuthPassword] as string;
            string domain   = this.ITransportContext.IParameterProvider[GenuineParameter.HttpAuthDomain] as string;

            this._hostRenewingSpan = GenuineUtility.ConvertToMilliseconds(iTransportContext.IParameterProvider[GenuineParameter.ClosePersistentConnectionAfterInactivity]) + GenuineUtility.ConvertToMilliseconds(iTransportContext.IParameterProvider[GenuineParameter.MaxTimeSpanToReconnect]);

            if (this._credentials != null || (userName != null && userName != string.Empty &&
                                              password != null && password != string.Empty))
            {
                this._useWebAuthentication = true;

                // and setup credentials
                if (this._credentials == null)
                {
                    if ((bool)this.ITransportContext.IParameterProvider[GenuineParameter.HttpUseDefaultCredentials])
                    {
                        this._credentials = CredentialCache.DefaultCredentials;
                    }
                    else
                    {
                        if (domain == null)
                        {
                            this._credentials = new NetworkCredential(userName, password);
                        }
                        else
                        {
                            this._credentials = new NetworkCredential(userName, password, domain);
                        }
                    }
                }
            }

            if ((bool)this.ITransportContext.IParameterProvider[GenuineParameter.HttpUseGlobalProxy])
            {
#if (FRM20)
                this._iWebProxy = WebRequest.DefaultWebProxy;
#else
                this._iWebProxy = GlobalProxySelection.Select;
#endif
            }
            else
            {
                if (!(this.ITransportContext.IParameterProvider[GenuineParameter.HttpProxyUri] is string))
                {
#if (FRM20)
                    this._iWebProxy = null;
#else
                    this._iWebProxy = GlobalProxySelection.GetEmptyWebProxy();
#endif
                }
                else
                {
                    this._iWebProxy = new WebProxy((string)this.ITransportContext.IParameterProvider[GenuineParameter.HttpProxyUri], (bool)this.ITransportContext.IParameterProvider[GenuineParameter.HttpBypassOnLocal]);
                }
            }

            this._httpAsynchronousRequestTimeout = GenuineUtility.ConvertToMilliseconds(iTransportContext.IParameterProvider[GenuineParameter.HttpAsynchronousRequestTimeout]);
        }
 /// <summary>
 /// Constructs an instance of the GeneralBroadcastSender class.
 /// </summary>
 /// <param name="court">The court.</param>
 /// <param name="iTransportContext">The Transport Ñontext.</param>
 public GeneralBroadcastSender(string court, ITransportContext iTransportContext)
 {
     this._court = court;
     this._iTransportContext = iTransportContext;
 }
        /// <summary>
        /// Constructs an instance of the TcpSocketInfo class.
        /// </summary>
        /// <param name="socket">The socket.</param>
        /// <param name="iTransportContext">Transport Context.</param>
        /// <param name="connectionName">The name of the connection.</param>
        /// <param name="typeOfSocket">The type of the socket used for debugging.</param>
        internal TcpSocketInfo(Socket socket, ITransportContext iTransportContext, string connectionName
            #if DEBUG
            ,string typeOfSocket
            #endif
            )
        {
            this.Socket = socket;
            this.ITransportContext = iTransportContext;
            this.ConnectionName = connectionName == null ? "~" + Guid.NewGuid().ToString("N") : connectionName;
            this.MaxSendSize = (int) this.ITransportContext.IParameterProvider[GenuineParameter.TcpMaxSendSize];

            #if DEBUG
            this._typeOfSocket = typeOfSocket;
            this._connectionNumber = Interlocked.Increment(ref _dbg_ConnectionCounter);
            #endif
        }
        /// <summary>
        /// Constructs the response to the specified message.
        /// </summary>
        /// <param name="sourceMessage">The source message.</param>
        /// <param name="iTransportHeaders">The transport headers.</param>
        /// <param name="stream">The message content.</param>
        public Message(Message sourceMessage, ITransportHeaders iTransportHeaders, Stream stream)
        {
            this.ITransportContext = sourceMessage.ITransportContext;
            this.ITransportHeaders = iTransportHeaders;
            //			this.Sender = sourceMessage.Recipient;
            this.Recipient = sourceMessage.Sender;
            this.ReplyToId = sourceMessage.MessageId;
            this.GenuineMessageType = sourceMessage.GenuineMessageType;
            this.Stream = stream;
            this.ConnectionName = sourceMessage.ConnectionName;
            this.SecuritySessionParameters = this.ITransportContext.FixSecuritySessionParameters(sourceMessage.SecuritySessionParameters);
            this.IsSynchronous = (this.SecuritySessionParameters.Attributes & SecuritySessionAttributes.ForceSync) != 0 ||
                ((bool) this.ITransportContext.IParameterProvider[GenuineParameter.SyncResponses] && (this.SecuritySessionParameters.Attributes & SecuritySessionAttributes.ForceAsync) == 0);

            if (this.ITransportHeaders != null)
                this.ITransportHeaders[TransportHeadersSenderEntryName] = this.Sender;

            this.MessageId = Interlocked.Increment(ref _currentMessageId);

            #if TRIAL
            if (this.MessageId > 3010)
                throw GenuineExceptions.Get_Channel_TrialConditionExceeded("The maximum number of messages restriction has been exceeded. You can not send more than 3000 messages using TRIAL version.");
            #endif
        }
 public AmqpProvider(Uri remoteUri, ITransportContext transport)
 {
     RemoteUri      = remoteUri;
     this.transport = transport;
 }
 /// <summary>
 /// Initializes the instance of the SyncSinkStackResponseProcessor class.
 /// </summary>
 /// <param name="iTransportContext">The Transport Context.</param>
 /// <param name="message">The source message.</param>
 public SyncSinkStackResponseProcessor(ITransportContext iTransportContext, Message message)
 {
     this._iTransportContext = iTransportContext;
     this._message = message;
 }
 /// <summary>
 /// Initializes an instance of the IPMulticastSender class.
 /// </summary>
 /// <param name="court">The name of the destination court.</param>
 /// <param name="iTransportContext">The Transport Context.</param>
 public IPMulticastSender(string court, ITransportContext iTransportContext)
     : base(court, iTransportContext)
 {
 }
        /// <summary>
        /// Constructs an instance of the Message class.
        /// </summary>
        /// <param name="iTransportContext">The Transport Context.</param>
        /// <param name="recipient">Recipient.</param>
        /// <param name="replyToId">Source id or zero.</param>
        /// <param name="iTransportHeaders">Transport headers.</param>
        /// <param name="stream">Message.</param>
        public Message(ITransportContext iTransportContext, HostInformation recipient, int replyToId, ITransportHeaders iTransportHeaders, Stream stream)
        {
            this.ITransportContext = iTransportContext;
            this.ITransportHeaders = iTransportHeaders;
            this.Recipient = recipient;
            this.ReplyToId = replyToId;
            this.Stream = stream;

            if (this.ITransportHeaders != null)
                this.ITransportHeaders[TransportHeadersSenderEntryName] = this.Sender;

            this.MessageId = Interlocked.Increment(ref _currentMessageId);

            #if TRIAL
            if (this.MessageId > 3001)
                throw GenuineExceptions.Get_Channel_TrialConditionExceeded("The maximum number of messages restriction has been exceeded. You can not send more than 3000 messages using TRIAL version.");
            #endif
        }
        /// <summary>
        /// Constructs an instance of the TcpConnectionManager class.
        /// </summary>
        /// <param name="iTransportContext">The transport context.</param>
        public TcpConnectionManager(ITransportContext iTransportContext)
            : base(iTransportContext)
        {
            this._onEndSending = new AsyncCallback(this.LowLevel_EndSending);
            this._internal_TimerCallback = new WaitCallback(this.Internal_TimerCallback);
            this._HalfSync_onContinueReceiving = new WaitCallback(this.Pool_ContinueHalfSyncReceiving);
            this._HalfSync_onEndReceiving = new AsyncCallback(this.LowLevel_HalfSync_EndReceiving);
            this._lowLevel_Client_PreventDelayedAck = new WaitCallback(this.LowLevel_Client_PreventDelayedAck);
            this._processObjectLateBoundHandler = new PersistentConnectionStorage.ProcessConnectionEventHandler(this.FindExpiredConnections);
            this._releaseConnections_InspectPersistentConnections = new PersistentConnectionStorage.ProcessConnectionEventHandler(this.ReleaseConnections_InspectPersistentConnections);

            this._tcpReadRequestBeforeProcessing = (bool) iTransportContext.IParameterProvider[GenuineParameter.TcpReadRequestBeforeProcessing];

            this.Local = new HostInformation("_gtcp://" + iTransportContext.HostIdentifier, iTransportContext);
            TimerProvider.Attach(this);
        }
Beispiel #43
0
 /// <summary>
 /// Creates an instance of the GenuineTcpServerTransportSink class.
 /// </summary>
 /// <param name="channel">The parent channel.</param>
 /// <param name="nextChannelSink">The next channel sink for futher processing.</param>
 /// <param name="iTransportContext">The Transport Context.</param>
 public GenuineUniversalServerTransportSink(BasicChannelWithSecurity channel, IServerChannelSink nextChannelSink, ITransportContext iTransportContext)
 {
     this.ITransportContext = iTransportContext;
     this._channel          = channel;
     this._nextChannelSink  = nextChannelSink;
 }
 /// <summary>
 /// Constructs an instance of the GenuineTcpClientTransportSinkProvider class.
 /// </summary>
 /// <param name="iTransportContext">Transport Context.</param>
 public GenuineTcpClientTransportSinkProvider(ITransportContext iTransportContext)
 {
     this.ITransportContext = iTransportContext;
 }
        /// <summary>
        /// Constructs an instance of the SharedMemoryConnection class.
        /// </summary>
        /// <param name="iTransportContext">The transport context.</param>
        /// <param name="name">The name of the shared chunk.</param>
        /// <param name="isServer">The role.</param>
        /// <param name="setCloseStatusOnExit">Indicates whether it is necessary to set the "closed" status on exit.</param>
        internal SharedMemoryConnection(ITransportContext iTransportContext, string name, bool isServer, bool setCloseStatusOnExit)
        {
            this.ITransportContext     = iTransportContext;
            this.ShareName             = "GenuineChannels_GShMem_" + name;
            this.IsServer              = isServer;
            this._setCloseStatusOnExit = setCloseStatusOnExit;

            this._shareSize            = (int)iTransportContext.IParameterProvider[GenuineParameter.SMShareSize];
            this._pingTimeOut          = GenuineUtility.ConvertToMilliseconds(iTransportContext.IParameterProvider[GenuineParameter.PersistentConnectionSendPingAfterInactivity]);
            this._closeAfterInactivity = GenuineUtility.ConvertToMilliseconds(iTransportContext.IParameterProvider[GenuineParameter.ClosePersistentConnectionAfterInactivity]);

            string localSideName  = (isServer ? "Server" : "Client");
            string remoteSideName = (isServer ? "Client" : "Server");

            IParameterProvider parameters = this.ITransportContext.IParameterProvider;

            // construct shared object names for the local side
            string readCompletedEventName = GenuineSharedMemoryChannel.ConstructSharedObjectName(
                this.ShareName + localSideName + "ReadCompleted", parameters);
            string writeCompletedEventName = GenuineSharedMemoryChannel.ConstructSharedObjectName(
                this.ShareName + localSideName + "WriteCompleted", parameters);

            // construct shared object names for the remote side
            string remoteReadCompletedEventName = GenuineSharedMemoryChannel.ConstructSharedObjectName(
                this.ShareName + remoteSideName + "ReadCompleted", parameters);
            string remoteWriteCompletedEventName = GenuineSharedMemoryChannel.ConstructSharedObjectName(
                this.ShareName + remoteSideName + "WriteCompleted", parameters);

            if (isServer)
            {
                if (this._shareSize < MIN_SHARE_SIZE || this._shareSize > MAX_SHARE_SIZE)
                {
                    throw GenuineExceptions.Get_Channel_InvalidParameter("SMShareSize");
                }

                this.LowLevel_CreateSharedMemory();
                this._closed           = 0;
                this._writtenShareSize = this._shareSize;

                this._receiveOffset    = 5;
                this._sendOffset       = (this._shareSize - 5) / 2;
                this._receiveSpaceSize = this._sendOffset - 5 - 8;
                this._sendSpaceSize    = this._shareSize - this._sendOffset - 8;

                this._namedEventReadCompleted        = NamedEvent.CreateNamedEvent(readCompletedEventName, false, true);
                this._namedEventWriteCompleted       = NamedEvent.CreateNamedEvent(writeCompletedEventName, false, true);
                this._namedEventRemoteReadCompleted  = NamedEvent.CreateNamedEvent(remoteReadCompletedEventName, false, true);
                this._namedEventRemoteWriteCompleted = NamedEvent.CreateNamedEvent(remoteWriteCompletedEventName, false, true);
            }
            else
            {
                this.OpenSharedMemory();

                if (this._closed != 0)
                {
                    throw GenuineExceptions.Get_Connect_CanNotConnectToRemoteHost(name, "Remote host has already closed the connection.");
                }

                this._shareSize = this._writtenShareSize;
                if (this._shareSize < MIN_SHARE_SIZE || this._shareSize > MAX_SHARE_SIZE)
                {
                    throw GenuineExceptions.Get_Channel_InvalidParameter("SMShareSize");
                }

                this._receiveOffset    = (this._shareSize - 5) / 2;
                this._sendOffset       = 5;
                this._receiveSpaceSize = this._shareSize - this._receiveOffset - 8;
                this._sendSpaceSize    = this._receiveOffset - 5 - 8;

                this._namedEventReadCompleted        = NamedEvent.OpenNamedEvent(readCompletedEventName);
                this._namedEventWriteCompleted       = NamedEvent.OpenNamedEvent(writeCompletedEventName);
                this._namedEventRemoteReadCompleted  = NamedEvent.OpenNamedEvent(remoteReadCompletedEventName);
                this._namedEventRemoteWriteCompleted = NamedEvent.OpenNamedEvent(remoteWriteCompletedEventName);
            }

            this._sendBuffer = new byte[this._sendSpaceSize];
        }
 /// <summary>
 /// Registers message handler.
 /// Overrides old message handlers with the same names.
 /// </summary>
 /// <param name="remoteUri">The URI of the remote host.</param>
 /// <param name="iTransportContext">Transport Context servicing a connection to the remote host.</param>
 public static void RegisterConnection(string remoteUri, ITransportContext iTransportContext)
 {
     _knownUris[remoteUri] = new WeakReference(iTransportContext);
 }
Beispiel #47
0
 /// <summary>
 /// Constructs an instance of the DirectExchangeManager class.
 /// </summary>
 /// <param name="iTransportContext">The Transport Context.</param>
 public DirectExchangeManager(ITransportContext iTransportContext)
 {
     this.ITransportContext = iTransportContext;
 }
        /// <summary>
        /// Makes message up from the IMessage.
        /// </summary>
        /// <param name="iTransportContext">The Transport Context.</param>
        /// <param name="iMessage">IMessage to make the message up from.</param>
        /// <param name="iTransportHeaders">Trasport headers.</param>
        /// <param name="stream">Message body.</param>
        /// <param name="isSynchronous">True if the invocation is synchronous.</param>
        /// <returns>An instance of the Message class.</returns>
        public static Message CreateOutcomingMessage(ITransportContext iTransportContext, IMessage iMessage, ITransportHeaders iTransportHeaders, Stream stream, bool isSynchronous)
        {
            // when microsoft guys start caring about detailed .NET remoting documentation???
            string url = (string) iMessage.Properties["__Uri"];
            string objectURI;

            string channelUri = GenuineUtility.Parse(url, out objectURI);
            if (objectURI == null)
                objectURI = url;	// not well-known object
            iTransportHeaders[TransportHeaderName_RemoteObjectUri] = objectURI;
            Message message = new Message(iTransportContext, null, 0, iTransportHeaders, stream);
            message.IMessage = iMessage;
            message.IsSynchronous = isSynchronous;

            if (iTransportHeaders[Message.TransportHeadersGenuineMessageType] != null)
                message.GenuineMessageType = (GenuineMessageType) iTransportHeaders[Message.TransportHeadersGenuineMessageType];

            return message;
        }
        /// <summary>
        /// Constructs an instance of the HttpClientConnection class.
        /// </summary>
        /// <param name="iTransportContext">The Transport Context.</param>
        /// <param name="connectionName">The name of the connection.</param>
        public HttpClientConnection(ITransportContext iTransportContext, string connectionName)
        {
            this.HostId = iTransportContext.BinaryHostIdentifier;
            this.HostIdAsString = iTransportContext.HostIdentifier;
            this.ConnectionName = connectionName;

            this.ITransportContext = iTransportContext;
            this.HttpClientConnectionManager = (HttpClientConnectionManager) this.ITransportContext.ConnectionManager;
            this.MessageContainer = new MessageContainer(iTransportContext);

            // the less buffer the less performance
            this.Sender_SendBuffer = new byte[35000];
            this.Sender_ReceiveBuffer = new byte[35000];
            this.Listener_ReceiveBuffer = new byte[35000];
            this.OnEndSending = new AsyncCallback(this.Callback_OnEndSending);
            this.OnEndReceiving = new AsyncCallback(this.Callback_OnEndReceiving);

            // cache all setting's values
            this._userAgent = this.ITransportContext.IParameterProvider[GenuineParameter.HttpWebUserAgent] as string;
            this._mimeMediaType = this.ITransportContext.IParameterProvider[GenuineParameter.HttpMimeMediaType] as string;
            if (this._userAgent == null)
                this._userAgent = @"Mozilla/4.0+ (compatible; MSIE 6.0; Windows " + Environment.OSVersion.Version +
                    "; Genuine HTTP Client Channel; MS .NET CLR " + Environment.Version.ToString() + ")";
            this._userAgent = Regex.Replace(this._userAgent, "\r|\n", " ", RegexOptions.None);

            this._useUnsafeConnectionSharing = (bool) this.ITransportContext.IParameterProvider[GenuineParameter.HttpUnsafeConnectionSharing];
            this._allowWriteStreamBuffering = (bool) this.ITransportContext.IParameterProvider[GenuineParameter.HttpAllowWriteStreamBuffering];

            this._keepalive = (bool) iTransportContext.IParameterProvider[GenuineParameter.HttpKeepAlive];
            this._credentials = this.ITransportContext.IParameterProvider[GenuineParameter.HttpAuthCredential] as ICredentials;
            string userName = this.ITransportContext.IParameterProvider[GenuineParameter.HttpAuthUserName] as string;
            string password = this.ITransportContext.IParameterProvider[GenuineParameter.HttpAuthPassword] as string;
            string domain = this.ITransportContext.IParameterProvider[GenuineParameter.HttpAuthDomain] as string;

            bool httpUseDefaultCredentials = (bool) this.ITransportContext.IParameterProvider[GenuineParameter.HttpUseDefaultCredentials];

            if (this._credentials != null || (userName != null && userName != string.Empty &&
                password != null && password != string.Empty) || httpUseDefaultCredentials)
            {
                this._useWebAuthentication = true;

                // and setup credentials
                if (this._credentials == null)
                {
                    if (httpUseDefaultCredentials)
                        this._credentials = CredentialCache.DefaultCredentials;
                    else
                    {
                        if (domain == null)
                            this._credentials = new NetworkCredential(userName, password);
                        else
                            this._credentials = new NetworkCredential(userName, password, domain);
                    }
                }
            }

            if ((bool) this.ITransportContext.IParameterProvider[GenuineParameter.HttpUseGlobalProxy])
            {
            #if (FRM20)
                this._iWebProxy = WebRequest.DefaultWebProxy;
            #else
                this._iWebProxy = GlobalProxySelection.Select;
            #endif
            }
            else
            {
                if (! (this.ITransportContext.IParameterProvider[GenuineParameter.HttpProxyUri] is string) )
                {
            #if (FRM20)
                    this._iWebProxy = null;
            #else
                    this._iWebProxy = GlobalProxySelection.GetEmptyWebProxy();
            #endif
                }
                else
                    this._iWebProxy = new WebProxy((string) this.ITransportContext.IParameterProvider[GenuineParameter.HttpProxyUri], (bool) this.ITransportContext.IParameterProvider[GenuineParameter.HttpBypassOnLocal]);
            }
        }
 /// <summary>
 /// Constructs an instance of the KnownHosts class.
 /// </summary>
 public KnownHosts(ITransportContext iTransportContext)
 {
     this.ITransportContext = iTransportContext;
     TimerProvider.Attach(this);
 }
 /// <summary>
 /// Constructs an instance of the GeneralConnection class.
 /// </summary>
 /// <param name="iTransportContext">The Transport Context.</param>
 public GeneralConnection(ITransportContext iTransportContext)
 {
     this.ITransportContext = iTransportContext;
     this.HostIdAsString = iTransportContext.HostIdentifier;
 }
Beispiel #52
0
 /// <inheritdoc />
 public Task CopyToAsync(IStream stream, ITransportContext context)
 {
     return(Implementation.CopyToAsync(stream.ToImplementation(), context.ToImplementation()));
 }
 /// <summary>
 /// Constructs an instance of the GenuineReceivingHandler class.
 /// </summary>
 /// <param name="iTransportContext">Transport context.</param>
 /// <param name="defaultTransportUser">Default transport user.</param>
 public GenuineReceivingHandler(ITransportContext iTransportContext, ITransportUser defaultTransportUser)
 {
     this.ITransportContext = iTransportContext;
     this.DefaultTransportUser = defaultTransportUser;
     this._waitCallback_InternalExecuteMessagewaitCallback = new WaitCallback(this.InternalExecuteMessage);
     TimerProvider.Attach(this);
 }
Beispiel #54
0
 /// <summary>
 /// Initializes an instance of the AsyncSinkStackResponseProcessor class.
 /// </summary>
 /// <param name="iTransportContext">The Transport Context.</param>
 /// <param name="message">Source message.</param>
 /// <param name="iClientChannelSinkStack">The client channel sink stack.</param>
 public AsyncSinkStackResponseProcessor(ITransportContext iTransportContext, Message message, IClientChannelSinkStack iClientChannelSinkStack)
 {
     this._iTransportContext       = iTransportContext;
     this._message                 = message;
     this._iClientChannelSinkStack = iClientChannelSinkStack;
 }
 /// <summary>
 /// Answers Genuine Channels URI and Transport Context via which access to the remote 
 /// MarshalByRefObject object is performed.
 /// </summary>
 /// <param name="marshalByRefObject">MarshalByRefObject instance to fetch the URI from.</param>
 /// <param name="uri">The uri.</param>
 /// <param name="iTransportContext">The transport context.</param>
 public static void FetchChannelUriFromMbr(MarshalByRefObject marshalByRefObject, out string uri, out ITransportContext iTransportContext)
 {
     IDictionary iDictionary = ChannelServices.GetChannelSinkProperties(marshalByRefObject);
     uri = iDictionary["GC_URI"] as string;
     iTransportContext = iDictionary["GC_TC"] as ITransportContext;
 }
        /// <summary>
        /// Registers the receiver and associate the provided object with it.
        /// Returns false if the receiver has already been registered.
        /// WARNING: does not check whether the receiver supports the required interface (via Reflection) 
        /// because this check requires client's dll.
        /// </summary>
        /// <param name="obj">The receiver being registered.</param>
        /// <param name="tag">The object associated with the receiver. This object is accessible when receiver is being unregistered or during filtering.</param>
        /// <param name="remoteGenuineUri">The uri of the remote host provided by any of Genuine Channels.</param>
        /// <param name="transportContext">The transport context of the remote host.</param>
        /// <returns>False if the receiver has been already registered.</returns>
        public bool Add(MarshalByRefObject obj, object tag, string remoteGenuineUri, ITransportContext transportContext)
        {
            if (obj == null)
                throw new ArgumentNullException("obj");

            BinaryLogWriter binaryLogWriter = GenuineLoggingServices.BinaryLogWriter;

            // check if it is in the list
            string uri = RemotingServices.GetObjectUri(obj);
            if (uri == null && ! RemotingServices.IsObjectOutOfAppDomain(obj))
            {
                // it was not marshalled
                RemotingServices.Marshal(obj);
                uri = RemotingServices.GetObjectUri(obj);
            }

            using (ReaderAutoLocker reader = new ReaderAutoLocker(this._readerWriterLock))
            {
                if (this._receivers.ContainsKey(uri))
                    return false;
            }

            // this check can not be performed because client's dll is required
            //			// check on the interface
            //			bool supportInterface = false;
            //			foreach(Type interfaceType in obj.GetType().GetInterfaces())
            //				if (interfaceType == this._interfaceToSupport)
            //				{
            //					supportInterface = true;
            //					break;
            //				}
            //			if (! supportInterface)
            //				throw GenuineExceptions.Get_Broadcast_ObjectDoesNotSupportDestinationInterface();

            // adds the object to the receiver list
            ReceiverInfo receiverInfo = new ReceiverInfo();
            receiverInfo.MbrObject = obj;
            receiverInfo.MbrUri = uri;
            receiverInfo.Tag = tag;

            if (binaryLogWriter != null)
            {
                try
                {
                    if (receiverInfo.MbrObject != null)
                        receiverInfo.DbgRemoteHost = GenuineUtility.FetchHostInformationFromMbr(receiverInfo.MbrObject);
                }
                catch(Exception ex)
                {
                    binaryLogWriter.WriteImplementationWarningEvent("Dispatcher.Add",
                        LogMessageType.Error, ex, GenuineUtility.CurrentThreadId, Thread.CurrentThread.Name,
                        "Can't get HostInformation from MbrObject.");
                }
            }

            ObjRef objRef = receiverInfo.MbrObject.CreateObjRef(typeof(MarshalByRefObject));
            receiverInfo.Local = objRef.IsFromThisAppDomain();

            // cache object's info to speed up sending thru Genuine Channels
            if (! receiverInfo.Local)
            {
                if (remoteGenuineUri != null)
                {
                    receiverInfo.IClientChannelSink = new GenuineTcpClientTransportSink(remoteGenuineUri, transportContext);
                }
                else
                {
                    // check whether the client sink has registered itself on this MBR
                    receiverInfo.IClientChannelSink = ChannelServices.GetChannelSinkProperties(obj)["GC_TS"] as IClientChannelSink;
                    if (receiverInfo.IClientChannelSink == null)
                        throw GenuineExceptions.Get_Broadcast_ClientSinkIsUnknown();
                }

                // object uri
                receiverInfo.SerializedObjRef = objRef;

            //				// and shell's uri
            //				string shellUri;
            //				ITransportContext iTransportContext;
            //				GenuineUtility.FetchChannelUriFromMbr(obj, out shellUri, out iTransportContext);
            //				if (shellUri == null)
            //					throw GenuineExceptions.Get_Send_NoSender(objRef.URI);
            //
            //				receiverInfo.ReceiverUri = shellUri;
            }

            // LOG:
            if ( binaryLogWriter != null && binaryLogWriter[LogCategory.BroadcastEngine] > 0 )
            {
                binaryLogWriter.WriteBroadcastEngineEvent(LogCategory.BroadcastEngine, "Dispatcher.Add",
                    LogMessageType.BroadcastRecipientAdded, null, null, receiverInfo.DbgRemoteHost, null,
                    GenuineUtility.CurrentThreadId, Thread.CurrentThread.Name,
                    null, null, false, this, null, true, receiverInfo,
                    null, null,
                    "The broadcast recipient is added.");
            }

            // register the sponsor to prevent unexpected reclaiming
            ILease lease = (ILease) RemotingServices.GetLifetimeService(obj);
            if (lease != null)
                lease.Register(this.GlobalSponsor);

            // and register it
            using (WriterAutoLocker writer = new WriterAutoLocker(this._readerWriterLock))
            {
                this._cachedReceiversInfoArray = null;
                this._receivers[uri] = receiverInfo;
            }
            return true;
        }
 /// <summary>
 /// Creates an instance of the GenuineTcpServerTransportSink class.
 /// </summary>
 /// <param name="channel">The parent channel.</param>
 /// <param name="nextChannelSink">The next channel sink for futher processing.</param>
 /// <param name="iTransportContext">The Transport Context.</param>
 public GenuineUniversalServerTransportSink(BasicChannelWithSecurity channel, IServerChannelSink nextChannelSink, ITransportContext iTransportContext)
 {
     this.ITransportContext = iTransportContext;
     this._channel = channel;
     this._nextChannelSink = nextChannelSink;
 }
 /// <summary>
 /// Constructs an instance of the ConnectionManager class.
 /// </summary>
 /// <param name="iTransportContext">The Transport context.</param>
 public ConnectionManager(ITransportContext iTransportContext)
 {
     this.ITransportContext = iTransportContext;
 }
Beispiel #59
0
 /// <summary>
 /// Initializes the instance of the SyncSinkStackResponseProcessor class.
 /// </summary>
 /// <param name="iTransportContext">The Transport Context.</param>
 /// <param name="message">The source message.</param>
 public SyncSinkStackResponseProcessor(ITransportContext iTransportContext, Message message)
 {
     this._iTransportContext = iTransportContext;
     this._message           = message;
 }
Beispiel #60
0
 /// <summary>
 /// Constructs an instance of the TcpSocketInfo class.
 /// </summary>
 /// <param name="socket">The socket.</param>
 /// <param name="iTransportContext">Transport Context.</param>
 /// <param name="connectionName">The name of the connection.</param>
 /// <param name="typeOfSocket">The type of the socket used for debugging.</param>
 internal TcpSocketInfo(Socket socket, ITransportContext iTransportContext, string connectionName, string typeOfSocket)