예제 #1
0
        public ListenerExceptionStatus Register(BaseUriWithWildcard path)
        {
            if (path.BaseAddress.Scheme == Uri.UriSchemeNetTcp)
            {
                if (transportType == TransportType.NamedPipe)
                {
                    return(ListenerExceptionStatus.ProtocolUnsupported);
                }

                maxQueueSize  = ListenerConfig.NetTcp.MaxPendingConnections;
                transportType = TransportType.Tcp;
            }
            else if (path.BaseAddress.Scheme == Uri.UriSchemeNetPipe)
            {
                if (transportType == TransportType.Tcp)
                {
                    return(ListenerExceptionStatus.ProtocolUnsupported);
                }

                maxQueueSize  = ListenerConfig.NetPipe.MaxPendingConnections;
                transportType = TransportType.NamedPipe;
            }
            else
            {
                return(ListenerExceptionStatus.ProtocolUnsupported);
            }

            ListenerExceptionStatus status;
            int registrationRetries = AppSettings.ListenerRegistrationRetryCount;

            do
            {
                status = RoutingTable.Start(this, path);
                if (status == ListenerExceptionStatus.ConflictingRegistration)
                {
                    if (registrationRetries > 0)
                    {
                        Thread.Sleep(AppSettings.ListenerRegistrationRetryDelay);
                    }
                }
                else
                {
                    break;
                }
            } while (registrationRetries-- > 0);

            if (status == ListenerExceptionStatus.Success)
            {
                paths.Add(path);
                IncrementUrisRegisteredCounters();
                OnRegisterCompleted();
            }

            return(status);
        }
        public ListenerExceptionStatus Register(BaseUriWithWildcard path)
        {
            if (path.BaseAddress.Scheme == Uri.UriSchemeNetTcp)
            {
                if (transportType == TransportType.NamedPipe)
                {
                    return(ListenerExceptionStatus.ProtocolUnsupported);
                }

                maxQueueSize  = ListenerConfig.NetTcp.MaxPendingConnections;
                transportType = TransportType.Tcp;
            }
            else if (path.BaseAddress.Scheme == Uri.UriSchemeNetPipe)
            {
                if (transportType == TransportType.Tcp)
                {
                    return(ListenerExceptionStatus.ProtocolUnsupported);
                }

                maxQueueSize  = ListenerConfig.NetPipe.MaxPendingConnections;
                transportType = TransportType.NamedPipe;
            }
            else
            {
                return(ListenerExceptionStatus.ProtocolUnsupported);
            }

            ListenerExceptionStatus status = RoutingTable.Start(this, path);

            if (status == ListenerExceptionStatus.Success)
            {
                paths.Add(path);
                IncrementUrisRegisteredCounters();
                OnRegisterCompleted();
            }

            return(status);
        }