Ejemplo n.º 1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // DI
            NinjectModule pointModule    = new PointModule();
            NinjectModule userDataModule = new UserDataModule();
            NinjectModule serviceModule  = new ServiceModule("DefaultConnection");
            var           kernel         = new StandardKernel(pointModule, userDataModule, serviceModule);

            DependencyResolver.SetResolver(new Ninject.Web.Mvc.NinjectDependencyResolver(kernel));
        }
Ejemplo n.º 2
0
        public static void onPlayerDissconnected(int peerID)
        {
            string     keyID   = peerID.ToString();
            ActiveUser oldUser = activeUsersColl.FindOne(x => x.peerId == keyID);

            if (oldUser != null)
            {
                //Debug.LogError ("Removing for id: " + peerID);
                activeUsersColl.Delete(oldUser.peerId);
                UserLoginInformation savedUser = userLoginColl.FindOne(x => x.username == oldUser.username);
                if (savedUser != null)
                {
                    savedUser.isLoggedIn = false;
                    updateLoginInfo(savedUser);
                }

                UserDataModule.userLogedOut(oldUser.username);
            }
        }
Ejemplo n.º 3
0
    private void handleLoginMsg(IIncommingMessage msg)
    {
        //Validate incoming message to make sure connection is safe
        Dictionary <string, string> data = new Dictionary <string, string> ();

        if (validateDecryptMsg(msg, out data) == false)
        {
            msg.Respond("Insecure request".ToBytes(), ResponseStatus.Unauthorized);
            return;
        }

        string errorMsg = "";

        if (checkLoginCredentials(data, out errorMsg) == false)
        {
            msg.Respond(errorMsg.ToBytes(), ResponseStatus.Failed);
            return;
        }

        UserLoginInformation user = new UserLoginInformation()
        {
            username   = data [AlbotDictKeys.username],
            password   = data [AlbotDictKeys.password],
            isLoggedIn = true
        };

        AlbotDBManager.updateLoginInfo(user);

        UserInfo storedInfo;

        if (AlbotDBManager.getUserData(user.username, out storedInfo) == false)
        {
            storedInfo = new UserInfo()
            {
                username    = user.username,
                logins      = "0",
                roomActions = "0",
                profilePic  = ClientIconManager.giveNewPlayerIconNumber().ToString()
            };
        }
        else
        {
            storedInfo.logins = (int.Parse(storedInfo.logins) + 1).ToString();
        }

        AlbotDBManager.updateGameStat(storedInfo);


        //Generate account data
        IAccountData accountData = null;

        if (generateAcountData(storedInfo, out accountData) == false)
        {
            msg.Respond("Error in generating accountData", ResponseStatus.Unauthorized);
            return;
        }

        // Setup auth extension
        var extension = msg.Peer.AddExtension(new UserExtension((msg.Peer)));

        extension.Load(accountData);
        var infoPacket = extension.CreateInfoPacket();

        // Finalize login
        FinalizeLogin(extension, user);
        msg.Respond(infoPacket.ToBytes(), ResponseStatus.Success);
        UserDataModule.onUserLogedIn(user.username);

        //Temp King tournament
        if (tempActiveUsers.ContainsKey(user.username) == false)
        {
            tempActiveUsers.Add(user.username, msg.Peer);
        }
        else
        {
            tempActiveUsers[user.username] = msg.Peer;
        }
    }