Exemple #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);
            }
        }
Exemple #3
0
 public DiscordProfile()
 {
     OnClientUpdated += (sender, e) =>
     {
         User.SetClient(Client);
         ConnectedAccounts.SetClientsInList(Client);
     };
 }
Exemple #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();
        }
Exemple #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);
     }
 }
Exemple #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);
            }
        }
Exemple #8
0
 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>();
     };
 }
Exemple #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;
            };
        }