public SessionManager(Config config, ProtocolManagerFactory protocolManagerFactory) { Trace.Call(config, protocolManagerFactory); if (config == null) { throw new ArgumentNullException("config"); } if (protocolManagerFactory == null) { throw new ArgumentNullException("protocolManagerFactory"); } _Config = config; _ProtocolManagerFactory = protocolManagerFactory; EngineAssemblyVersion = Engine.AssemblyVersion; EngineProtocolVersion = Engine.ProtocolVersion; string[] users = (string[])Engine.Config["Engine/Users/Users"]; if (users == null) { Console.WriteLine("No Engine/Users/*, aborting...\n"); Environment.Exit(1); } foreach (string user in users) { // skip local session if (user == "local") { continue; } #if LOG4NET _Logger.Debug("Creating Session for User "+user); #endif _Sessions.Add(user, new Session(_Config, _ProtocolManagerFactory, user)); } }
public Session(Config config, ProtocolManagerFactory protocolManagerFactory, string username) { Trace.Call(config, protocolManagerFactory, username); if (config == null) { throw new ArgumentNullException("config"); } if (protocolManagerFactory == null) { throw new ArgumentNullException("protocolManagerFactory"); } if (username == null) { throw new ArgumentNullException("username"); } _Config = config; _ProtocolManagerFactory = protocolManagerFactory; _Username = username; _FrontendManagers = new Dictionary<string, FrontendManager>(); _ProtocolManagers = new List<IProtocolManager>(); _UserConfig = new UserConfig(config, username); _Chats = new List<ChatModel>(); _SessionChat = new SessionChatModel("smuxi", "smuxi"); _Chats.Add(_SessionChat); }
public UserListController(Config config) { if (config == null) { throw new ArgumentNullException("config"); } f_Config = config; f_Prefix = "Engine/Users"; }
public UserConfig(Config config, string username) { _Config = config; // HACK: The Changed event was introduced in 0.7.2, for backwards // compatibility with 0.7.x server we need to suppress remoting // exceptions here try { // we can't use events over remoting if (!RemotingServices.IsTransparentProxy(config)) { _Config.Changed += OnConfigChanged; } } catch (Exception ex) { #if LOG4NET _Logger.Warn( "UserConfig() registration of Config.Changed event failed, " + "ignoring for backwards compatibility with 0.7.x servers...", ex ); #endif } _UserPrefix = "Engine/Users/"+username+"/"; }
private static void ManageUser(bool addUser, bool delUser, bool modUser, bool listUsers, string username, string password) { Config config = new Config(); UserListController controller = new UserListController(config); if (addUser) { config.Load(); controller.AddUser(username, password); config.Save(); Console.WriteLine( _("User \"{0}\" successfully added to server."), username ); Environment.Exit(0); } else if (modUser) { config.Load(); controller.ModifyUser(username, password); config.Save(); Console.WriteLine( _("User \"{0}\" successfully modified."), username ); Environment.Exit(0); } else if (delUser) { config.Load(); controller.DeleteUser(username); config.Save(); Console.WriteLine( _("User \"{0}\" successfully deleted from server."), username ); Environment.Exit(0); } else if (listUsers) { config.Load(); var users = controller.GetUsers(); Console.WriteLine(_("Users:")); foreach (var user in users) { if (user == "local") { // is not a real user and could cause confusion continue; } Console.WriteLine("\t{0}", user); } Environment.Exit(0); } }
public static void Init() { if (_IsInitialized) { return; } _IsInitialized = true; var asm = Assembly.GetEntryAssembly(); if (asm == null) { asm = Assembly.GetAssembly(typeof(Engine)); } var asm_name = asm.GetName(false); _Version = asm_name.Version; _VersionNumber = asm_name.Version.ToString(); var distVersion = Defines.DistVersion; if (!String.IsNullOrEmpty(distVersion)) { distVersion = String.Format(" ({0})", distVersion); } _VersionString = String.Format( "{0} {1}{2} - running on {3} {4}", Path.GetFileNameWithoutExtension(asm_name.Name), _Version, distVersion, Platform.OperatingSystem, Platform.Architecture ); _Config = new Config(); _Config.Load(); _Config.Save(); string location = Assembly.GetExecutingAssembly().Location; _ProtocolManagerFactory = new ProtocolManagerFactory(); _ProtocolManagerFactory.LoadAllProtocolManagers(Path.GetDirectoryName(location)); _SessionManager = new SessionManager(_Config, _ProtocolManagerFactory); }
public static void Init() { if (_IsInitialized) { return; } _IsInitialized = true; Assembly asm = Assembly.GetAssembly(typeof(Engine)); AssemblyName asm_name = asm.GetName(false); AssemblyProductAttribute pr = (AssemblyProductAttribute)asm.GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0]; _Version = asm_name.Version; _VersionNumber = asm_name.Version.ToString(); _VersionString = String.Format("{0} {1} - running on {2} {3}", pr.Product, _Version, Platform.OperatingSystem, Platform.Architecture); _Config = new Config(); _Config.Load(); _Config.Save(); string location = Assembly.GetExecutingAssembly().Location; _ProtocolManagerFactory = new ProtocolManagerFactory(); _ProtocolManagerFactory.LoadAllProtocolManagers(Path.GetDirectoryName(location)); _SessionManager = new SessionManager(_Config, _ProtocolManagerFactory); }
public static void Init() { if (_IsInitialized) { return; } _IsInitialized = true; var asm = Assembly.GetEntryAssembly(); if (asm == null) { asm = Assembly.GetAssembly(typeof(Engine)); } var asm_name = asm.GetName(false); var distVersion = Defines.DistVersion; if (!String.IsNullOrEmpty(distVersion)) { distVersion = String.Format(" ({0})", distVersion); } _VersionString = String.Format( "{0} {1}{2} - running on {3} {4}", Path.GetFileNameWithoutExtension(asm_name.Name), AssemblyVersion, distVersion, Platform.OperatingSystem, Platform.Architecture ); _Config = new Config(); _Config.Load(); _Config.Save(); string location = Path.GetDirectoryName(asm.Location); if (String.IsNullOrEmpty(location) && Environment.OSVersion.Platform == PlatformID.Unix) { // we are mkbundled var locationBuilder = new StringBuilder(8192); if (Mono.Unix.Native.Syscall.readlink("/proc/self/exe", locationBuilder) >= 0) { location = Path.GetDirectoryName(locationBuilder.ToString()); } } _ProtocolManagerFactory = new ProtocolManagerFactory(); _ProtocolManagerFactory.LoadAllProtocolManagers(location); _SessionManager = new SessionManager(_Config, _ProtocolManagerFactory); }
public UserConfig(Config config, string username) { _Config = config; _UserPrefix = "Engine/Users/"+username+"/"; }