示例#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);
            }
        }
示例#3
0
 public DiscordProfile()
 {
     OnClientUpdated += (sender, e) =>
     {
         User.SetClient(Client);
         ConnectedAccounts.SetClientsInList(Client);
     };
 }
示例#4
0
        private void button7_Click(object sender, RoutedEventArgs e)
        {
            //Connected accounts
            ConnectedAccounts connectedAccounts = new ConnectedAccounts();
            var p = new Point();

            connectedAccounts.Top  = this.PointToScreen(p).Y;
            connectedAccounts.Left = this.PointToScreen(p).X;
            connectedAccounts.ShowDialog();
        }
示例#5
0
 /// <summary>
 /// Checks if the Account has a connected Character
 /// </summary>
 /// <param name="accountName">Name of the Account</param>
 /// <returns></returns>
 public bool AccountIsConnected(string accountName)
 {
     try
     {
         return(ConnectedAccounts.Any(cc => cc.Key.Equals(accountName)));
     }
     catch (Exception ex)
     {
         Logger.Log.Error("General Error", ex);
         return(false);
     }
 }
示例#6
0
        /// <summary>
        /// Disconnect Account from server.
        /// </summary>
        /// <param name="accountName">Account who wants to disconnect.</param>
        public void DisconnectAccount(string accountName)
        {
            try
            {
                ConnectedAccounts.Remove(accountName);

                Logger.Log.DebugFormat($"[WCF] Account {accountName} has been disconnected.");
            }
            catch (Exception ex)
            {
                Logger.Log.Error("General Error", ex);
            }
        }
        /// <summary>
        /// Disconnect Account from server.
        /// </summary>
        /// <param name="accountName">Account who wants to disconnect.</param>
        public void DisconnectAccount(string accountName)
        {
            try
            {
                ConnectedAccounts.Remove(accountName);

                // inform clients
                ICommunicationCallback callback = OperationContext.Current.GetCallbackChannel <ICommunicationCallback>();
                callback.DisconnectAccountCallback(accountName);

                Logger.Log.DebugFormat($"[WCF] Account {accountName} has been disconnected.");
            }
            catch (Exception ex)
            {
                Logger.Log.Error("General Error", ex);
            }
        }
示例#8
0
文件: Login.cs 项目: xuan2261/Anarchy
 internal Login()
 {
     OnClientUpdated += (sender, e) =>
     {
         User.SetClient(Client);
         Guilds.SetClientsInList(Client);
         Relationships.SetClientsInList(Client);
         Settings.SetClient(Client);
         PrivateChannels.SetClientsInList(Client);
         ClientGuildSettings.SetClientsInList(Client);
         ConnectedAccounts.SetClientsInList(Client);
         Presences.SetClientsInList(Client);
     };
     JsonUpdated += (sender, json) =>
     {
         Guilds          = json.Value <JArray>("guilds").PopulateListJson <LoginGuild>();
         PrivateChannels = json.Value <JArray>("private_channels").PopulateListJson <PrivateChannel>();
         Presences       = json.Value <JArray>("presences").PopulateListJson <DiscordPresence>();
     };
 }
示例#9
0
        internal LoginEventArgs()
        {
            OnClientUpdated += (sender, e) =>
            {
                User.SetClient(Client);
                Relationships.SetClientsInList(Client);
                Settings.SetClient(Client);
                PrivateChannels.SetClientsInList(Client);
                ClientGuildSettings.SetClientsInList(Client);
                ConnectedAccounts.SetClientsInList(Client);
                Presences.SetClientsInList(Client);

                List <MinimalGuild> guilds = new List <MinimalGuild>();
                foreach (var obj in _guilds)
                {
                    guilds.Add((Client.User.Type == DiscordUserType.User ? obj.ToObject <SocketGuild>() : obj.ToObject <MinimalGuild>()).SetClient(Client));
                }
                Guilds = guilds;
            };
        }