Example #1
0
        public RegisteredClient Register(int identity)
        {
            RegisteredClient rc = new RegisteredClient(Guid.NewGuid().ToString(), identity);

            _registrationList.TryAdd(rc.SocketKey, rc);
            return(rc);
        }
Example #2
0
        public User(string connectionID, RegisteredClient rc)
        {
            RegistrationTicket = rc;
            ConnectionID       = connectionID;

            ReadyForPayloads = false;

            //RemoteControllers = new List<User>();
            //NotificationManager = new NotificationManager();
            IdleManager = new IdleManager(this);
            Connected   = true;
            _lastSeen   = DateTime.UtcNow;
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //check logged in
            if (Session["user"] == null)
            {
                string redirectPath = System.Web.Configuration.WebConfigurationManager.AppSettings["index"].ToString();
                Response.Redirect(redirectPath);
                return;
            }

            var state = Request.Cookies["shootr.state"];

            //string decoded = HttpUtility.UrlDecode(state.Value);
            //var rc = JsonConvert.DeserializeObject<RegisteredClient>(decoded);
            SocketKey = Guid.NewGuid().ToString();
            EmpiresInSpace.Users x = (EmpiresInSpace.Users)Session["user"];
            var rc = new RegisteredClient(SocketKey, x.id);

            //rc.RegistrationID = (string)Session["user"];
            Game.Instance.RegistrationHandler.Register(rc);
        }
Example #4
0
 public RegisteredClient Register(RegisteredClient existing)
 {
     //existing.RegistrationID = Guid.NewGuid().ToString();
     _registrationList.TryAdd(existing.SocketKey, existing);
     return(existing);
 }
Example #5
0
        /// <summary>
        /// Retrieves the game's configuration
        /// </summary>
        /// <returns>The game's configuration</returns>
        public object initializeClient(string connectionId, RegisteredClient rc)
        {
            if (!UserHandler.UserExistsAndReady(connectionId))
            {
                try
                {
                    lock (_locker)
                    {
                        User user = UserHandler.FindUserByIdentity(rc.UserId);


                        if (user == null)
                        {
                            // checkuserMaximum - not more than one million users
                            if (UserHandler.TotalActiveUsers >= 1000000)
                            {
                                return(new
                                {
                                    ServerFull = true
                                });
                            }
                            else
                            {
                                user = new User(connectionId, rc)
                                {
                                    Controller = false
                                };
                                UserHandler.AddUser(user);
                            }
                        }
                        else
                        {
                            string previousConnectionID = user.ConnectionID;
                            UserHandler.ReassignUser(connectionId, user);


                            if (user.Connected) // Check if it's a duplicate login
                            {
                                GetContext().Clients.Client(previousConnectionID).controlTransferred();
                                //user.NotificationManager.Notify("Transfering control to this browser.  You were already logged in.");
                            }
                            else
                            {
                                //ship.Disposed = false;
                                //ship.LifeController.HealFull();
                                user.Connected = true;
                            }

                            user.IdleManager.RecordActivity();
                            user.IdleManager.Idle = false;
                        }

                        //GameHandler.AddShipToGame(ship);
                    }

                    // var fields = bc.getUserBordersData(rc.UserId);

                    /*
                     * object[] result;
                     * result = new object[fields.Count];
                     * for (int i = 0; i < 2; i++)
                     * {
                     *  result[i] = fields[i];
                     * }
                     * return new { x = result };
                     */
                    object ret = new
                    {
                        //Configuration = Configuration,
                        ServerFull = false
                                     //BorderMap = bc.getUserBordersData(rc.UserId)[0]  //works
                                     //BorderMap = fields


                                     /*CompressionContracts = new
                                      * {
                                      *  PayloadContract = _payloadManager.Compressor.PayloadCompressionContract,
                                      *  CollidableContract = _payloadManager.Compressor.CollidableCompressionContract,
                                      *  ShipContract = _payloadManager.Compressor.ShipCompressionContract,
                                      *  BulletContract = _payloadManager.Compressor.BulletCompressionContract,
                                      *  LeaderboardEntryContract = _payloadManager.Compressor.LeaderboardEntryCompressionContract,
                                      *  PowerupContract = _payloadManager.Compressor.PowerupCompressionContract
                                      * },
                                      */
                                     //ShipID = UserHandler.GetUserShip(connectionId).ID,
                                     //ShipName = UserHandler.GetUserShip(connectionId).Name
                    };



                    return(ret);
                }
                catch (Exception e)
                {
                    this.bc.writeExceptionToLog(e);
                }
            }

            return(null);
        }