Пример #1
0
 /// <summary>
 /// Registers that the given Account has now logged in
 /// </summary>
 /// <param name="accountName">Name of the Account.</param>
 /// <param name="sessionId">SessionId of the login.</param>
 public bool ConnectAccount(string accountName, int sessionId)
 {
     try
     {
         // Account cant connect twice
         if (ConnectedAccounts.ContainsKey(accountName))
         {
             Logger.Log.DebugFormat($"[WCF] Account {accountName} is already connected.");
             return(false);
         }
         else
         {
             // TODO: move in own method, cannot do this here because it needs to be called by
             //       a client who wants to know if the Account is allowed to connect without
             // doing it actually
             Logger.Log.DebugFormat($"[WCF] Account {accountName} has connected.");
             ConnectedAccounts.Add(accountName, sessionId);
             return(true);
         }
     }
     catch (Exception ex)
     {
         Logger.Log.Error("General Error", ex);
         return(false);
     }
 }
        /// <summary>
        /// Registers that the given Account has now logged in
        /// </summary>
        /// <param name="accountName">Name of the Account.</param>
        /// <param name="sessionId">SessionId of the login.</param>
        public bool ConnectAccount(string accountName, int sessionId)
        {
            try
            {
                // Account cant connect twice
                if (ConnectedAccounts.ContainsKey(accountName))
                {
                    Logger.Log.DebugFormat($"[WCF] Account {accountName} is already connected.");
                    return(false);
                }
                else
                {
                    // TODO: move in own method, cannot do this here because it needs to be called by a client who wants to know if the
                    // Account is allowed to connect without doing it actually
                    Logger.Log.DebugFormat($"[WCF] Account {accountName} has connected.");
                    ConnectedAccounts.Add(accountName, sessionId);

                    // inform clients
                    ICommunicationCallback callback = OperationContext.Current.GetCallbackChannel <ICommunicationCallback>();
                    callback.ConnectAccountCallback(accountName, sessionId);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                Logger.Log.Error("General Error", ex);
                return(false);
            }
        }