public static void HandleChannel(Session session, NetworkObject networkObject) { string channelName = NetworkObjectField.ReadStringField(networkObject.GetField(1)); if (string.IsNullOrWhiteSpace(channelName)) { return; } ClientChannelAction action = (ClientChannelAction)NetworkObjectField.ReadIntField(networkObject.GetField(0)); switch (action) { case ClientChannelAction.Join: { Channel channel = ChannelManager.GetChannel(channelName); channel.AddMember(session.Character); break; } case ClientChannelAction.Leave: { Channel channel = ChannelManager.GetChannel(channelName); channel?.RemoveMember(session.Character); break; } case ClientChannelAction.Message: { Channel channel = ChannelManager.GetChannel(channelName); channel.BroadcastMessage(session.Character, NetworkObjectField.ReadStringField(networkObject.GetField(2))); break; } } }
public static void Handle08(Session session, NetworkObject networkObject) { NetworkObjectField.ReadIntField(networkObject.GetField(0)); string recipient = NetworkObjectField.ReadStringField(networkObject.GetField(1)); string message = NetworkObjectField.ReadStringField(networkObject.GetField(2)); ConversationManager.SendMessage(session, recipient, message); }
public override void FromNetworkObject(NetworkObject networkObject) { Server = NetworkObjectField.ReadStringField(networkObject.GetField(0)); Name = NetworkObjectField.ReadStringField(networkObject.GetField(1)); Guid = (uint)NetworkObjectField.ReadIntField(networkObject.GetField(2)); Sequence = (uint)NetworkObjectField.ReadLongField(networkObject.GetField(3)); Unknown1 = NetworkObjectField.ReadStringField(networkObject.GetField(4)); Unknown1 = Name; // ?? }
public static void HandleFriendList(Session session, NetworkObject networkObject) { ClientFriendAction action = (ClientFriendAction)NetworkObjectField.ReadIntField(networkObject.GetField(0)); switch (action) { case ClientFriendAction.Create: session.FriendManager.AddAccountAll(NetworkObjectField.ReadStringField(networkObject.GetField(1))); break; case ClientFriendAction.Remove: session.FriendManager.RemoveAccountAll(NetworkObjectField.ReadStringField(networkObject.GetField(1))); break; default: log.Warn($"[{session.Account.Username}] Invalid FriendAction {action}!"); break; } }
public override void FromNetworkObject(NetworkObject class63_0) { this.string_0 = NetworkObjectField.ReadStringField(class63_0.GetField(0)); }
public override void FromNetworkObject(NetworkObject fellowship) { Name = NetworkObjectField.ReadStringField(fellowship.GetField(0)); Unknown1 = (Enum16)NetworkObjectField.ReadIntField(fellowship.GetField(1)); }
public static void HandleAuthenticate(Session session, NetworkObject networkObject) { void SendAuthenticationError(byte code) { var errorCode = new NetworkObject(); errorCode.AddField(0, NetworkObjectField.CreateIntField(code)); var authenticationError = new NetworkObject(); authenticationError.AddField(0, NetworkObjectField.CreateIntField((int)ObjectOpcode.AuthenticateError)); authenticationError.AddField(1, NetworkObjectField.CreateObjectField(errorCode)); session.EnqueuePacket(new ServerAuthenticationPacket(authenticationError)); } string username = NetworkObjectField.ReadStringField(networkObject.GetField(2)); string password = NetworkObjectField.ReadStringField(networkObject.GetField(3)); string version = NetworkObjectField.ReadStringField(networkObject.GetField(5)); string accountName = NetworkObjectField.ReadStringField(networkObject.GetField(6)); CharacterObject characterObject = new CharacterObject(); characterObject.FromNetworkObject(networkObject.GetField(4).ReadObject()); if (string.IsNullOrWhiteSpace(username) || username.Length > 20 || username == "Anonymous") { SendAuthenticationError(0); return; } // anonymous login ignored if (version != "1.0.1.14") { SendAuthenticationError(1); return; } AccountInfo accountInfo = DatabaseManager.Database.GetAccount(username); if (accountInfo == null) { accountInfo = DatabaseManager.Database.CreateAccount(username, password, session.Remote.Address.ToString(), Privilege.All); } else { // validate existing account if (!BCryptProvider.Verify(password, accountInfo.Password)) { SendAuthenticationError(0); return; } } log.Info($"Account: {accountInfo.Username}, Character: {characterObject.Name} has signed in!"); DatabaseManager.Database.UpdateAccount(accountInfo.Id, session.Remote.Address.ToString()); var authentication = new NetworkObject(); authentication.AddField(0, NetworkObjectField.CreateIntField((int)ObjectOpcode.Authenticate)); authentication.AddField(1, NetworkObjectField.CreateIntField((int)accountInfo.Privileges)); session.EnqueuePacket(new ServerAuthenticationPacket(authentication)); characterObject.Sequence = NetworkManager.SessionSequence.Dequeue(); session.SignIn(accountInfo, accountName, characterObject); }