Beispiel #1
0
        internal Listener(ServerAssociationParameters parameters, StartAssociation acceptor)
        {
            ListenerInfo info = new ListenerInfo();

            info.Parameters    = parameters;
            info.StartDelegate = acceptor;

            _applications.Add(parameters.CalledAE, info);

            _ipEndPoint = parameters.LocalEndPoint;
        }
Beispiel #2
0
        public static bool Listen(ServerAssociationParameters parameters, StartAssociation acceptor)
        {
            lock (_syncLock)
            {
                Listener theListener;
                if (_listeners.TryGetValue(parameters.LocalEndPoint, out theListener))
                {
                    ListenerInfo info = new ListenerInfo();

                    info.StartDelegate = acceptor;
                    info.Parameters    = parameters;

                    if (theListener._applications.ContainsKey(parameters.CalledAE))
                    {
                        LogAdapter.Logger.ErrorWithFormat("Already listening with AE {0} on {1}", parameters.CalledAE,
                                                          parameters.LocalEndPoint.ToString());
                        return(false);
                    }

                    theListener._applications.Add(parameters.CalledAE, info);
                    LogAdapter.Logger.InfoWithFormat("Starting to listen with AE {0} on existing port {1}", parameters.CalledAE,
                                                     parameters.LocalEndPoint.ToString());
                }
                else
                {
                    theListener = new Listener(parameters, acceptor);
                    if (!theListener.StartListening())
                    {
                        LogAdapter.Logger.ErrorWithFormat("Unexpected error starting to listen on {0}", parameters.LocalEndPoint.ToString());
                        return(false);
                    }

                    _listeners[parameters.LocalEndPoint] = theListener;
                    theListener.StartThread();

                    LogAdapter.Logger.InfoWithFormat("Starting to listen with AE {0} on port {1}", parameters.CalledAE,
                                                     parameters.LocalEndPoint.ToString());
                }

                return(true);
            }
        }