/* Thor Server 2.0 Project - Codenamed "Stockholm" Copyright 2008 - 2009 Joe Hegarty This file is part of The Thor Server 2.0 Project - Codenamed "Stockholm". The Thor Server 2.0 Project - Codenamed "Stockholm" is free software: you can redistribute it and/or modify it under the terms of the Microsoft Public License The Thor Server Project is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Microsoft Public License for more details. You should have received a copy of the Microsoft Public License along with The Thor Server Project. If not, see http://www.opensource.org/licenses/ms-pl.html */ using System; using System.Text; using System.Collections.Generic; using System.Linq; using StockholmLibrary.Net; using StockholmLibrary.Game.Sessions; using StockholmLibrary.Game.Packets.Server; using StockholmLibrary.Game.Packets.Client; using StockholmLibrary.Data; namespace StockholmLibrary.Game.Handlers.Specific { //------------------------------------ public class SessionUserHandler { Session _session; //********************************************** public SessionUserHandler(Session session) { _session = session; SendInitialLoginInfo(); Stockholm.Get().PacketManager.RegisterPeerHandler(_session.Peer, Packets.Client.EClientPacket.GET_INFO, new PacketRoutingInfo.ProcessPacketDelegate(HandleGetInfo)); Stockholm.Get().PacketManager.RegisterPeerHandler(_session.Peer, Packets.Client.EClientPacket.GET_CREDITS, new PacketRoutingInfo.ProcessPacketDelegate(HandleGetCredits)); Stockholm.Get().PacketManager.RegisterPeerHandler(_session.Peer, Packets.Client.EClientPacket.SCR_GET_USER_INFO, new PacketRoutingInfo.ProcessPacketDelegate(HandleGetSubscriptionInfo)); Stockholm.Get().PacketManager.RegisterPeerHandler(_session.Peer, Packets.Client.EClientPacket.GET_AVAILABLE_BADGES, new PacketRoutingInfo.ProcessPacketDelegate(HandleGetAvailableBadges)); } //********************************************** private void SendInitialLoginInfo() { // Rights list FuseRightsPacket packet = new FuseRightsPacket(Stockholm.Get().GameManager.RoleManager.GetRightsList(_session.User.RoleID)); _session.Peer.EnqueuePacket(packet); // Login Ok _session.Peer.EnqueuePacket(new LoginOkPacket()); // Allowed Sets _session.Peer.EnqueuePacket(new ClientAllowedSetsPacket()); } //********************************************** private void HandleGetInfo(ClientPacket packet) { UserObjectPacket userObjectPacket = new UserObjectPacket(_session.User); _session.Peer.EnqueuePacket(userObjectPacket); } //********************************************** private void HandleGetCredits(ClientPacket packet) { WalletBalancePacket walletBalancePacket = new WalletBalancePacket(_session.User.Credits); _session.Peer.EnqueuePacket(walletBalancePacket); } //********************************************** private void HandleGetSubscriptionInfo(ClientPacket packet) { GetSubscriptionInfoPacket getSubscriptionInfoPacket = new GetSubscriptionInfoPacket(); getSubscriptionInfoPacket.Deserialise(packet); if (getSubscriptionInfoPacket.SubscriptionType == "club_habbo") { SubscriptionInfoPacket subscriptionInfoPacket = new SubscriptionInfoPacket(getSubscriptionInfoPacket.SubscriptionType, _session.User); _session.Peer.EnqueuePacket(subscriptionInfoPacket); } } //********************************************** private void HandleGetAvailableBadges(ClientPacket packet) { List badgeList = Stockholm.Get().GameManager.RoleManager.GetBadgeList(_session.User.RoleID); BadgeListPacket badgeListPacket = new BadgeListPacket(badgeList, _session.User.CurrentBadge); _session.Peer.EnqueuePacket(badgeListPacket); } } }