public IEnumerable <GuestRoomListing> GetGuestRoomListings(string categoryID, int maximumAmount = 30) { HabboDistributor habboDistributor = CoreManager.ServerCore.GetHabboDistributor(); List <int> loadedRoomIDs = new List <int>(); // TODO: Dusokay current rooms using (ISession db = CoreManager.ServerCore.GetDatabaseSession()) { IList <Room> rooms = db.CreateCriteria <Room>() .Add(Restrictions.Eq("category_id", categoryID)) .Add( new NotExpression( new InExpression("room_id", loadedRoomIDs.Cast <object>().ToArray()))) .AddOrder(Order.Desc("last_entry")) .SetMaxResults(maximumAmount - loadedRoomIDs.Count) .List <Room>(); foreach (Room room in rooms) { yield return(new GuestRoomListing { ID = room.room_id, Name = room.name, Description = room.description, Owner = habboDistributor.GetHabbo(room.owner_id), // TODO: Other values Population = 0 // If people were inside it would already be loaded. }); } } }
internal GameSocket(ServerChildTcpSocket socket, GameSocketProtocol protocol) { _internalSocket = socket; _lengthBuffer = new byte[protocol.Reader.LengthBytes]; Habbo = HabboDistributor.GetPreLoginHabbo(this); }
internal GameSocket(ServerChildTcpSocket socket, GameSocketManager manager) { _internalSocket = socket; _lengthBuffer = new byte[manager.Protocol.Reader.LengthBytes]; GameSocketManager = manager; GameSocketManager.Protocol.HandlerInvokerManager[this] = new GameSocketMessageHandlerInvoker(); Habbo = HabboDistributor.GetPreLoginHabbo(this); }
public void ParsePacket(Session session, Message message) { string sso = message.NextString(); //Application.Logging.WriteLine(string.Format("SSO Ticket: {0}", sso)); var loadMyHabbo = new HabboDistributor().GetHabbo(sso); session.Habbo = loadMyHabbo; var response = new Message(SendHeaders.InitHotelView); session.SendPacket(response); }
private static void ProcessMessengerSearch(Habbo sender, IncomingMessage message) { string searchString = message.PopPrefixedString(); List <IHI.Database.Habbo> matching; // Using IHIDB.Habbo rather than IHIDB.Friend because this will be passed to the HabboDistributor using (ISession db = CoreManager.ServerCore.GetDatabaseSession()) { matching = db.CreateCriteria <IHI.Database.Habbo>(). Add(new LikeExpression("username", searchString + "%")). SetMaxResults(20). // TODO: External config List <IHI.Database.Habbo>() as List <IHI.Database.Habbo>; } List <IBefriendable> friends = new List <IBefriendable>(); List <IBefriendable> strangers = new List <IBefriendable>(); MessengerObject messenger = sender.GetMessenger(); HabboDistributor habboDistributor = CoreManager.ServerCore.GetHabboDistributor(); foreach (IHI.Database.Habbo match in matching) { IBefriendable habbo = habboDistributor.GetHabbo(match); if (messenger.IsFriend(habbo)) { friends.Add(habbo); } else { strangers.Add(habbo); } } new MMessengerSearchResults(friends, strangers).Send(sender); }
public void BootTaskPrepareHabbos() { StandardOut.Notice("Habbo Distributor", StringLocale.GetString("CORE:BOOT_HABBODISTRIBUTOR_PREPARE")); HabboDistributor = new HabboDistributor(); StandardOut.Notice("Habbo Distributor", StringLocale.GetString("CORE:BOOT_HABBODISTRIBUTOR_READY")); }
internal BootResult Boot(string configPath) { try { _textEncoding = Encoding.UTF8; // TODO: Move this to an external config. #region Standard Out _standardOut = new StandardOut(); _standardOut.PrintNotice("Text Encoding => Set to " + _textEncoding.EncodingName); _standardOut.PrintNotice("Standard Out => Ready"); #endregion _config = new XmlConfig(configPath); bool mainInstallRequired = PreInstall(); // Register the main installation if required. #region Load Plugins _standardOut.PrintNotice("Plugin Manager => Loading plugins..."); _pluginManager = new PluginManager(); XmlNodeList pluginNodes = GetConfig().GetInternalDocument().SelectNodes("/config/plugins/plugin"); foreach (XmlNode pluginNode in pluginNodes) { GetPluginManager().LoadPluginAtPath( Path.Combine( Directory.GetCurrentDirectory(), "plugins", pluginNode.Attributes["filename"].InnerText)); } _standardOut.PrintNotice("Plugin Manager => Plugins loaded!"); #endregion CoreManager.InstallerCore.Run(); if (mainInstallRequired) { SaveConfigInstallation(); } #region Config _standardOut.PrintNotice("Config File => Loaded"); _standardOut.SetImportance( (StandardOutImportance) _config.ValueAsByte("/config/standardout/importance", (byte)StandardOutImportance.Debug)); #endregion #region Database _standardOut.PrintNotice("MySQL => Preparing database connection settings..."); try { MySqlConnectionStringBuilder connectionString = new MySqlConnectionStringBuilder { Server = _config.ValueAsString( "/config/mysql/host"), Port = _config.ValueAsUint( "/config/mysql/port", 3306), UserID = _config.ValueAsString( "/config/mysql/user"), Password = _config.ValueAsString( "/config/mysql/password"), Database = _config.ValueAsString( "/config/mysql/database"), Pooling = true, MinimumPoolSize = _config.ValueAsUint( "/config/mysql/minpoolsize", 1), MaximumPoolSize = _config.ValueAsUint( "/config/mysql/maxpoolsize", 25) }; PrepareSessionFactory(connectionString.ConnectionString); _standardOut.PrintNotice("MySQL => Testing connection..."); using (ISession db = GetDatabaseSession()) { if (!db.IsConnected) { throw new Exception("Unknown cause"); } } } catch (Exception ex) { _standardOut.PrintError("MySQL => Connection failed!"); throw; } _standardOut.PrintNotice("MySQL => Connected!"); #endregion #region Distributors _standardOut.PrintNotice("Habbo Distributor => Constructing..."); _habboDistributor = new HabboDistributor(); _standardOut.PrintNotice("Habbo Distributor => Ready"); #endregion #region Figure Factory _standardOut.PrintNotice("Habbo Figure Factory => Constructing..."); _habboFigureFactory = new HabboFigureFactory(); _standardOut.PrintNotice("Habbo Figure Factory => Ready"); #endregion // TODO: Download Requirements #region Permissions _standardOut.PrintNotice("Permission Manager => Constructing..."); _permissionManager = new PermissionManager(); _standardOut.PrintNotice("Permission Manager => Ready"); #endregion // TODO: Write Dynamic Client Files // TODO: Authenticate with IHINet #region Network _standardOut.PrintNotice("Connection Manager => Starting..."); _connectionManager = new IonTcpConnectionManager(_config.ValueAsString("/config/network/host"), _config.ValueAsInt("/config/network/port", 14478)); _connectionManager.GetListener().Start(); _standardOut.PrintNotice("Connection Manager => Ready!"); _standardOut.PrintNotice("Web Admin => Starting..."); _webAdminManager = new WebAdminManager(_config.ValueAsUshort("/config/webadmin/port", 14480)); _standardOut.PrintNotice("Web Admin => Ready!"); #endregion #region Start Plugins PluginManager pluginManager = GetPluginManager(); _standardOut.PrintNotice("Plugin Manager => Starting plugins..."); foreach (Plugin plugin in pluginManager.GetLoadedPlugins()) { pluginManager.StartPlugin(plugin); } _standardOut.PrintNotice("Plugin Manager => Plugins started!"); #endregion _standardOut.PrintImportant("IHI is now functional!"); return(BootResult.AllClear); } catch (Exception e) { _standardOut.PrintException(e); if (e is MappingException) { return(BootResult.MySQLMappingFailure); } return(BootResult.UnknownFailure); } }
public void BootTaskPrepareHabbos() { ConsoleManager.Notice("Habbo Distributor", StringLocale.GetString("CORE:BOOT_HABBODISTRIBUTOR_PREPARE")); HabboDistributor = new HabboDistributor(); ConsoleManager.Notice("Habbo Distributor", StringLocale.GetString("CORE:BOOT_HABBODISTRIBUTOR_READY")); }