Has() public method

public Has ( SessionID sessionID ) : bool
sessionID SessionID
return bool
コード例 #1
0
 /// <summary>
 /// Add new session, either at start-up or as an ad-hoc operation
 /// </summary>
 /// <param name="sessionID">ID of new session<param>
 /// <param name="dict">config settings for new session</param></param>
 /// <returns>true if session added successfully, false if session already exists or is not an initiator</returns>
 public bool AddSession(SessionID sessionID, Dictionary dict)
 {
     if (dict.GetString(SessionSettings.CONNECTION_TYPE) == "initiator" && !sessionIDs_.Contains(sessionID))
     {
         Session session = sessionFactory_.Create(sessionID, dict);
         lock (sync_)
         {
             if (!_settings.Has(sessionID))  // session won't be in settings if ad-hoc creation after startup
             {
                 _settings.Set(sessionID, dict);
             }
             sessionIDs_.Add(sessionID);
             sessions_[sessionID] = session;
             SetDisconnected(sessionID);
         }
         return(true);
     }
     return(false);
 }
コード例 #2
0
        /// <summary>
        /// Add new session as an ad-hoc (dynamic) operation
        /// </summary>
        /// <param name="sessionID">ID of new session</param>
        /// <param name="dict">config settings for new session</param>
        /// <returns>true if session added successfully, false if session already exists or is not an initiator</returns>
        public bool AddSession(SessionID sessionID, Dictionary dict)
        {
            lock (_settings)
                if (!_settings.Has(sessionID))      // session won't be in settings if ad-hoc creation after startup
                {
                    _settings.Set(sessionID, dict); // need to to this here to merge in default config settings
                }
                else
                {
                    return(false);
                }                 // session already exists

            if (CreateSession(sessionID, dict))
            {
                return(true);
            }

            lock (_settings) // failed to create new session
                _settings.Remove(sessionID);
            return(false);
        }
コード例 #3
0
        /// <summary>
        /// Add new session as an ad-oc (dynamic) operation
        /// </summary>
        /// <param name="sessionID">ID of new session<param>
        /// <param name="dict">config settings for new session</param></param>
        /// <returns>true if session added successfully, false if session already exists or is not an acceptor</returns>
        public bool AddSession(SessionID sessionID, Dictionary dict)
        {
            lock (GdaxPrototyping.Common.Core.Threading.TThreadingHelpers.MainLockable)
                if (!settings_.Has(sessionID))      // session won't be in settings if ad-hoc creation after startup
                {
                    settings_.Set(sessionID, dict); // need to to this here to merge in default config settings
                }
                else
                {
                    return(false);
                }                 // session already exists

            if (CreateSession(sessionID, dict))
            {
                return(true);
            }

            lock (GdaxPrototyping.Common.Core.Threading.TThreadingHelpers.MainLockable) // failed to create session, so remove from settings
                settings_.Remove(sessionID);
            return(false);
        }