Ejemplo n.º 1
0
        public bool IsCompatible(IConnectionElement element)
        {
            RelayedSocketElement relayedSocketElement = element as RelayedSocketElement;

            if (relayedSocketElement == null)
            {
                return(false);
            }
            if (this.innerBinding == null && relayedSocketElement.InnerBinding == null)
            {
                return(this.nameSettings.IsCompatible(relayedSocketElement.nameSettings));
            }
            return(this.innerBinding == relayedSocketElement.InnerBinding);
        }
Ejemplo n.º 2
0
        public HybridConnectionInitiator(BindingContext context, TcpRelayTransportBindingElement transportBindingElement, int bufferSize, TokenProvider tokenProvider, RelayTransportProtectionMode transportProtection)
        {
            this.bufferSize = bufferSize;
            NameSettings nameSetting = new NameSettings();

            nameSetting.ServiceSettings.TransportProtection = transportProtection;
            nameSetting.ServiceSettings.ListenerType        = ListenerType.HybridConnection;
            IConnectionElement relayedSocketElement = new RelayedSocketElement(context, nameSetting, tokenProvider, SocketSecurityRole.None);

            this.relayedSocketInitiator = (new DemuxSocketElement(relayedSocketElement, "relayed")).CreateInitiator(bufferSize);
            IConnectionElement demuxSocketElement = new DemuxSocketElement(relayedSocketElement, "direct");
            Binding            binding            = HybridConnectionElement.CreateDirectControlBindingElement(context, transportBindingElement, demuxSocketElement);

            this.directSocketInitiator = new DirectSocketInitiator(bufferSize, binding);
            this.connectionId          = Guid.NewGuid();
        }
        public HybridConnectionListener(BindingContext context, TcpRelayTransportBindingElement transportBindingElement, int bufferSize, Uri uri, NameSettings nameSettings, TokenProvider tokenProvider)
        {
            this.bufferSize = bufferSize;
            IConnectionElement relayedSocketElement = new RelayedSocketElement(context, nameSettings, tokenProvider, SocketSecurityRole.None);
            DemuxSocketManager demuxSocketManager   = new DemuxSocketManager(relayedSocketElement, bufferSize, uri);
            IConnectionElement demuxSocketElement   = new DemuxSocketElement(relayedSocketElement, "relayed", demuxSocketManager);

            this.relayedSocketListener = demuxSocketElement.CreateListener(bufferSize, uri);
            this.relayedSocketAcceptor = new HybridConnectionListener.ConnectionAcceptor(this, this.relayedSocketListener, HybridConnectionListener.HybridConnectionSocketType.Relayed);
            IConnectionElement connectionElement = new DemuxSocketElement(relayedSocketElement, "direct", demuxSocketManager);
            Binding            binding           = HybridConnectionElement.CreateDirectControlBindingElement(context, transportBindingElement, connectionElement);

            this.directSocketListener = (new DirectSocketElement(binding)).CreateListener(bufferSize, uri);
            this.directSocketAcceptor = new HybridConnectionListener.ConnectionAcceptor(this, this.directSocketListener, HybridConnectionListener.HybridConnectionSocketType.Direct);
            this.connectionQueue      = new InputQueue <HybridConnection>();
            this.connectionTable      = new Dictionary <Guid, HybridConnection>();
        }