// Use this for initialization void Start() { server = new WebSocketServerManager(port); client = new WebSocketClientManager("ws://" + ipAddress + ":" + port + "/", WebSocketClientManager.DataType.Text); client.OnWebSocketError += (ms) => localSting = ms; client.ReceiveTextMessage += (ms) => localSting = ms; }
protected override void Awake() { base.Awake(); _poolManager = FindObjectOfType <PoolManager>(); _wssManager = FindObjectOfType <WebSocketServerManager>(); _gameManager = FindObjectOfType <GameManager>(); _wssManager.OnPlayerConnect += OnPlayerConnect; _wssManager.OnPlayerDisconnect += OnPlayerDisconnect; _wssManager.OnMessageReceive += OnMessageReceive; _gameManager.OnUserAdd += OnUserAdd; _gameManager.OnUserRemove += OnUserRemove; _messageFactorySystem = FindObjectOfType <MessageFactorySystem>(); _uiSystem = FindObjectOfType <UISystem>(); _messageFactorySystem.OnChangeAvatarMessage += OnChangeAvatarMessage; _messageFactorySystem.OnChangeStateMessage += OnChangeStateMessage; _uiSystem.OnCountingFinish += OnCountingFinish; }
protected override void Awake() { base.Awake(); _wssManager = FindObjectOfType <WebSocketServerManager>(); _gameManager = FindObjectOfType <GameManager>(); _wssManager.OnPlayerConnect += OnPlayerConnect; _wssManager.OnPlayerDisconnect += OnPlayerDisconnect; _wssManager.OnMessageReceive += OnMessageReceive; _messageFactorySystem = FindObjectOfType <MessageFactorySystem>(); _messageFactorySystem.OnSwipeMessage += OnSwipeMessage; _playersByUser = new Dictionary <UserModel, Player>(); foreach (var user in _gameManager.Users) { if (user != null) { _playersByUser.Add(user, _boat.AddPlayer(user.AvatarId)); } } }
public static void InitWebsocketManager() { webSocketServerManager = new WebSocketServerManager(Essential.GetConfig().data["websocket.url"]); }
public void Initialize() { Essential.consoleWriter = new ConsoleWriter(Console.Out); Console.SetOut(Essential.consoleWriter); try { Console.WindowWidth = 130; Console.WindowHeight = 36; } catch { } Essential.ServerStarted = DateTime.Now; Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(); Console.WriteLine(@" ______ _ _ _ "); Console.WriteLine(@" | ____| | | (_) | |"); Console.WriteLine(@" | |__ ___ ___ ___ _ __ | |_ _ __ _| |"); Console.WriteLine(@" | __| / __/ __|/ _ \ '_ \| __| |/ _` | |"); Console.WriteLine(@" | |____\__ \__ \ __/ | | | |_| | (_| | |"); Console.WriteLine(@" |______|___/___/\___|_| |_|\__|_|\__,_|_|"); Console.WriteLine(); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(" Essential Emulator Build " + Build + " by " + Creator); Console.WriteLine(); Console.WriteLine(" Credits to: Meth0d (Uber), Sojobo (Phoenix), Juniori (GTE) & Rootkit (Essential)"); Console.WriteLine(); Console.ResetColor(); try { Essential.Configuration = new ConfigurationData("config.conf"); DateTime now = DateTime.Now; try { Essential.SWFDirectory = Essential.GetConfig().data["web.api.furni.hof_furni"]; } catch { } if (!Directory.Exists("API")) { Directory.CreateDirectory("API"); } DatabaseServer dbServer = new DatabaseServer(Essential.GetConfig().data["db.hostname"], uint.Parse(Essential.GetConfig().data["db.port"]), Essential.GetConfig().data["db.username"], Essential.GetConfig().data["db.password"]); Database database = new Database(Essential.GetConfig().data["db.name"], uint.Parse(Essential.GetConfig().data["db.pool.minsize"]), uint.Parse(Essential.GetConfig().data["db.pool.maxsize"])); Essential.DatabaseManager = new DatabaseManager(dbServer, database); GroupsPartsData.InitGroups(); try { using (DatabaseClient dbClient = Essential.GetDatabase().GetClient()) { dbClient.ExecuteQuery("SET @@global.sql_mode= '';"); dbClient.ExecuteQuery("UPDATE users SET online = '0'"); dbClient.ExecuteQuery("UPDATE rooms SET users_now = '0'"); } Essential.Internal_Game.ContinueLoading(); } catch { } Essential.Internal_Game = new Game(int.Parse(Essential.GetConfig().data["game.tcp.conlimit"])); Essential.PacketManager = new PacketManager(); Essential.PacketManager.Load(); Essential.mhandler = new MobileHandler(); Essential.mhandler.Load(); Console.WriteLine(Essential.PacketManager.Count + " Packets loaded!"); Essential.antiAdSystem = new AntiAd(); Essential.MusListener = new MusListener(Essential.GetConfig().data["mus.tcp.bindip"], int.Parse(Essential.GetConfig().data["mus.tcp.port"]), Essential.GetConfig().data["mus.tcp.allowedaddr"].Split(new char[] { ';' }), 20); Essential.SocketsManager = new SocketsManager(Essential.GetConfig().data["game.tcp.bindip"], int.Parse(Essential.GetConfig().data["game.tcp.port"]), int.Parse(Essential.GetConfig().data["game.tcp.conlimit"])); //ConnectionManage = new ConnectionHandeling(Essential.GetConfig().data["game.tcp.port"], int.Parse(Essential.GetConfig().data["game.tcp.conlimit"]), int.Parse(Essential.GetConfig().data["game.tcp.conlimit"]), true); Essential.HeadImagerURL = Essential.GetConfig().data["eventstream.imager.url"]; using (DatabaseClient dbClient = Essential.GetDatabase().GetClient()) { dbClient.ExecuteQuery("UPDATE server_status SET bannerdata='" + EssentialEnvironment.globalCrypto.Prime + ":" + EssentialEnvironment.globalCrypto.Generator + "';"); } Essential.SocketsManager.method_3().method_0(); webSocketServerManager = new WebSocketServerManager(Essential.GetConfig().data["websocket.url"]); Console.WriteLine("Server started at " + Essential.GetConfig().data["websocket.url"]); webManager = new WebManager(); TimeSpan timeSpan = DateTime.Now - now; Logging.WriteLine(string.Concat(new object[] { "Server -> READY! (", timeSpan.Seconds, " s, ", timeSpan.Milliseconds, " ms)" })); using (DatabaseClient dbClient = Essential.GetDatabase().GetClient()) { dbClient.ExecuteQuery("UPDATE server_status SET server_started='" + Convert.ToInt32(GetUnixTimestamp()) + "'"); } Console.Beep(); } catch (KeyNotFoundException KeyNotFoundException) { Logging.WriteLine("Failed to boot, key not found: " + KeyNotFoundException); Logging.WriteLine("Press any key to shut down ..."); Console.ReadKey(true); Essential.Destroy(); } catch (InvalidOperationException ex) { Logging.WriteLine("Failed to initialize EssentialEmulator: " + ex.Message); Logging.WriteLine("Press any key to shut down ..."); Console.ReadKey(true); Essential.Destroy(); } }
public WebSocketServerMiddleware(RequestDelegate next, WebSocketServerManager manager) { _next = next; _manager = manager; }
public void Initialize() { HabboIM.ServerStarted = DateTime.Now; Console.Title = "HabboIM Emulator wird gestartet.."; Console.SetWindowPosition(0, 0); Console.SetWindowSize(100, 20); Console.BackgroundColor = ConsoleColor.Black; Console.CursorVisible = false; Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; try { Console.WriteLine(); Console.Clear(); Console.ForegroundColor = ConsoleColor.Black; Console.WriteLine(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ "); Console.Write(" @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@ "); Console.WriteLine(""); Console.Write(" @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@ "); Console.WriteLine(""); Console.Write(" @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@ "); Console.WriteLine(""); Console.Write(" @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@ "); Console.WriteLine(""); Console.Write(" @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@ "); Console.WriteLine(""); Console.Write(" @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*************************************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.WriteLine(""); Console.Write(" @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*************************************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.WriteLine(""); Console.Write(" @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*************************************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.WriteLine(""); Console.Write(" @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*************************************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.WriteLine(""); Console.Write(" @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*************************************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.WriteLine(""); Console.Write(" @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*************************************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.WriteLine(""); Console.Write(" @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@ "); Console.WriteLine(""); Console.Write(" @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@ "); Console.WriteLine(""); Console.Write(" @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@ "); Console.WriteLine(""); Console.Write(" @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@ "); Console.WriteLine(""); Console.WriteLine(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ "); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(" "); Console.WriteLine(" " + Version); Console.WriteLine(" " + Developer); Console.WriteLine(" Lizenz: " + licence); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine("____________________________________________________________________________________________________"); Console.WriteLine(); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Lotto gestartet! Nächste Ziehung um " + (hour_lastlotto+1) + ":00 Uhr"); Console.ResetColor(); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; try { DateTime now = DateTime.Now; try { HabboIM.Configuration = new ConfigurationData("config.conf"); Check(); DatabaseServer dbServer = new DatabaseServer(HabboIM.GetConfig().data["db.hostname"], uint.Parse(HabboIM.GetConfig().data["db.port"]), HabboIM.GetConfig().data["db.username"], HabboIM.GetConfig().data["db.password"]); Database database = new Database(HabboIM.GetConfig().data["db.name"], uint.Parse(HabboIM.GetConfig().data["db.pool.minsize"]), uint.Parse(HabboIM.GetConfig().data["db.pool.maxsize"])); HabboIM.DatabaseManager = new DatabaseManager(dbServer, database); } catch { Logging.WriteLine("Der Emulator wurde falsch konfiguriert!"); Logging.WriteLine("Press any key to shut down ..."); Console.ReadKey(true); HabboIM.Destroy(); } try { using (DatabaseClient dbClient = HabboIM.GetDatabase().GetClient()) { dbClient.ExecuteQuery("SET @@global.sql_mode= '';"); dbClient.ExecuteQuery("UPDATE users SET online = '0' WHERE online = '1' "); dbClient.ExecuteQuery("UPDATE rooms SET users_now = '0' WHERE users_now > 0"); DataRow DataRow; DataRow = dbClient.ReadDataRow("SHOW COLUMNS FROM `items` WHERE field = 'fw_count'"); DataRow DataRow2; DataRow2 = dbClient.ReadDataRow("SHOW COLUMNS FROM `items` WHERE field = 'extra_data'"); if (DataRow != null || DataRow2 != null) { if (DoYouWantContinue("Remember get backups before continue! Do you want continue? [Y/N]")) { if (DataRow != null) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("UPDATING ITEMS POSSIBLY TAKE A LONG TIME! DONT SHUTDOWN EMULATOR! PLEASE WAIT!"); Console.ForegroundColor = ConsoleColor.Gray; Console.Write("Items werden geupdatet (Feuerwerke) ..."); dbClient.ExecuteQuery("DROP TABLE IF EXISTS items_firework", int.MaxValue); dbClient.ExecuteQuery("CREATE TABLE IF NOT EXISTS `items_firework` (`item_id` int(10) unsigned NOT NULL, `fw_count` int(10) NOT NULL, PRIMARY KEY (`item_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;", int.MaxValue); dbClient.ExecuteQuery("INSERT INTO items_firework SELECT Id, fw_count FROM items WHERE fw_count > 0;", int.MaxValue); dbClient.ExecuteQuery("ALTER TABLE items DROP fw_count", int.MaxValue); Console.WriteLine("Erfolgreich!"); } if (DataRow2 != null) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("UPDATING ITEMS POSSIBLY TAKE A LONG TIME! DONT SHUTDOWN EMULATOR! PLEASE WAIT!"); Console.ForegroundColor = ConsoleColor.Gray; Console.Write("Items werden geupdatet (Extra data) ..."); dbClient.ExecuteQuery("DROP TABLE IF EXISTS items_extra_data", int.MaxValue); dbClient.ExecuteQuery("CREATE TABLE IF NOT EXISTS `items_extra_data` (`item_id` int(10) unsigned NOT NULL, `extra_data` text NOT NULL, PRIMARY KEY (`item_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;", int.MaxValue); dbClient.ExecuteQuery("INSERT INTO items_extra_data SELECT Id, extra_data FROM items WHERE extra_data != '';", int.MaxValue); dbClient.ExecuteQuery("ALTER TABLE items DROP extra_data", int.MaxValue); Console.WriteLine("Erfolgreich!"); } } else { Console.BackgroundColor = ConsoleColor.Black; Logging.WriteLine("Press any key to shut down ..."); Console.ReadKey(true); HabboIM.Destroy(); Logging.WriteLine("Press any key to close window ..."); Console.ReadKey(true); Environment.Exit(0); return; } } } //HabboIM.ConnectionManage.method_7(); HabboIM.Internal_Game.ContinueLoading(); } catch { } Console.BackgroundColor = ConsoleColor.Black; try { HabboIM.Internal_Game = new Game(int.Parse(HabboIM.GetConfig().data["game.tcp.conlimit"])); } catch { Console.BackgroundColor = ConsoleColor.Black; Logging.WriteLine("Fehler bei den Permissions"); Logging.WriteLine("Press any key to shut down ..."); Console.ReadKey(true); HabboIM.Destroy(); } try { HabboIM.PacketManager = new PacketManager(); HabboIM.PacketManager.Handshake(); HabboIM.PacketManager.Messenger(); HabboIM.PacketManager.Navigator(); HabboIM.PacketManager.RoomsAction(); HabboIM.PacketManager.RoomsAvatar(); HabboIM.PacketManager.RoomsChat(); HabboIM.PacketManager.RoomsEngine(); HabboIM.PacketManager.RoomsFurniture(); HabboIM.PacketManager.RoomsPets(); HabboIM.PacketManager.RoomsPools(); HabboIM.PacketManager.RoomsSession(); HabboIM.PacketManager.RoomsSettings(); HabboIM.PacketManager.Catalog(); HabboIM.PacketManager.Marketplace(); HabboIM.PacketManager.Recycler(); HabboIM.PacketManager.Quest(); HabboIM.PacketManager.InventoryAchievements(); HabboIM.PacketManager.InventoryAvatarFX(); HabboIM.PacketManager.InventoryBadges(); HabboIM.PacketManager.InventoryFurni(); HabboIM.PacketManager.InventoryPurse(); HabboIM.PacketManager.InventoryTrading(); HabboIM.PacketManager.Avatar(); HabboIM.PacketManager.Users(); HabboIM.PacketManager.Register(); HabboIM.PacketManager.Help(); HabboIM.PacketManager.Sound(); HabboIM.PacketManager.Wired(); HabboIM.PacketManager.Jukebox(); HabboIM.PacketManager.FriendStream(); } catch { Console.BackgroundColor = ConsoleColor.Black; Logging.WriteLine("Fehler bei wat weiß ich."); Logging.WriteLine("Press any key to shut down ..."); Console.ReadKey(true); HabboIM.Destroy(); } try { HabboIM.webSocketManager = new WebSocketServerManager(HabboIM.GetConfig().data["websockets.url"]); HabboIM.MusListener = new MusListener(HabboIM.GetConfig().data["mus.tcp.bindip"], int.Parse(HabboIM.GetConfig().data["mus.tcp.port"]), HabboIM.GetConfig().data["mus.tcp.allowedaddr"].Split(new char[] { ';' }), 20); HabboIM.SocketsManager = new SocketsManager(HabboIM.GetConfig().data["game.tcp.bindip"], int.Parse(HabboIM.GetConfig().data["game.tcp.port"]), int.Parse(HabboIM.GetConfig().data["game.tcp.conlimit"])); HabboIM.SocketsManager.method_3().method_0(); } catch { Console.BackgroundColor = ConsoleColor.Black; Logging.WriteLine("MUS Verbindung fehlgeschlagen!"); Logging.WriteLine("Press any key to shut down ..."); Console.ReadKey(true); HabboIM.Destroy(); } TimeSpan timeSpan = DateTime.Now - now; Console.BackgroundColor = ConsoleColor.Black; Logging.WriteLine(string.Concat(new object[] { "HabboIM -> BEREIT! (", timeSpan.Seconds, " s, ", timeSpan.Milliseconds, " ms)" })); Console.Beep(); } catch (KeyNotFoundException KeyNotFoundException) { Console.BackgroundColor = ConsoleColor.Black; Logging.WriteLine("Failed to boot, key not found: " + KeyNotFoundException); Logging.WriteLine("Press any key to shut down ..."); Console.ReadKey(true); HabboIM.Destroy(); } catch (InvalidOperationException ex) { Console.BackgroundColor = ConsoleColor.Black; Logging.WriteLine("Failed to initialize Unicorn: " + ex.Message); Logging.WriteLine("Press any key to shut down ..."); Console.ReadKey(true); HabboIM.Destroy(); } } catch { Console.BackgroundColor = ConsoleColor.Black; Logging.WriteLine("Configuration not found "); Logging.WriteLine("Press any key to shut down ..."); Console.ReadKey(true); HabboIM.Destroy(); } }