public Connection GetConnection(SlioAddress endpoint)
        {
            var connectionEntry = GetConnectionEntry(endpoint);

            lock (connectionEntry)
            {
                var connection = connectionEntry.GetConnection();
                if (connection == null || !connection.IsConnected)
                {
                    if (connection != null && !connection.IsConnected)
                    {
                        connection.Dispose();
                        connection = null;
                    }
                    if (connection == null)
                    {
                        var newConnection = new OutboundConnection(serviceProvider);
                        try
                        {
                            newConnection.Connect(endpoint);
                        }
                        catch
                        {
                            newConnection.Dispose();
                            throw;
                        }

                        connection = newConnection;
                        connectionEntry.Connections.Add(newConnection);
                    }
                }
                return(connection);
            }
        }
        public void ConnectionTerminated(SlioAddress address, Connection connection)
        {
            var connectionEntry = GetConnectionEntry(address);

            lock (connectionEntry)
            {
                connectionEntry.Connections.Remove(connection);
            }
        }
        public void Connected(SlioAddress address, Connection connection)
        {
            var connectionEntry = GetConnectionEntry(address);

            lock (connectionEntry)
            {
                connectionEntry.Connections.Add(connection);
            }
        }
Exemplo n.º 4
0
        private ConnectionListenerOptions GetMembershipServiceOptions(SlioAddress address)
        {
            if (clusterMembershipServiceOptions == null)
            {
                return(gatewayMembershipServiceOptions);
            }
            if (gatewayMembershipServiceOptions == null)
            {
                return(clusterMembershipServiceOptions);
            }
            if (address == null)
            {
                return(gatewayMembershipServiceOptions);
            }

            return(gatewayMembershipServiceOptions.OutsideAddress == address
                ? (ConnectionListenerOptions)gatewayMembershipServiceOptions
                : clusterMembershipServiceOptions);
        }
Exemplo n.º 5
0
 internal SystemTarget(SlioAddress address, Identity identity)
 {
     Address  = address;
     Identity = identity;
 }
 public ConnectionEntry(SlioAddress endpoint)
 {
     this.endpoint = endpoint;
 }
 private ConnectionEntry GetConnectionEntry(SlioAddress endpoint)
 {
     return(connections.GetOrAdd(endpoint, connectionEntryFactory));
 }