namespace OubHackMS.Servers.Handlers
{
    using OubHackMS.Core;
    using OubHackMS.Logging;
    using OubHackMS.Servers;
    using OubHackMS.Users;
    using System;
    using System.IO;
    using System.Net.Sockets;

    internal class PacketRegistration : PacketHandler
    {
        private UserDB userdb;

        public PacketRegistration(OubHackMS parent) : base(parent)
        {
            base.sIndex = 9;
            this.userdb = (UserDB) base.parent.GetClass("UserDB");
        }

        public override void doWork(NetworkStream str)
        {
            BinaryReader reader = new BinaryReader(str);
            BinaryWriter writer = new BinaryWriter(str);
            base.sIndex = 9;
            long lSessionID = reader.ReadInt64();
            long num2 = reader.ReadInt64();
            User user = this.userdb.getBySessionID(lSessionID);
            if ((user != null) && (user.lSteamID == 0L))
            {
                this.userdb.doLogout(user);
                user.update("steam_id_64", num2);
                base.parent.Log(Level.USER_LOG_FILE, new object[] { user.sUsername, "Registered Steam ID : " + num2 });
                writer.Write(true);
            }
            else
            {
                writer.Write(false);
            }
        }
    }
}

