Beispiel #1
0
        public void Start()
        {
            RockGenerator.Generate(domain, Settings.NUM_ROCKS);
            domain.Clean();

            // Upload the Server's domain
            // We're just using UpdateId 1, as this will be the only update from the server
            lobbySpace.Put("components", "1", JsonBuilder.BuildComponentsJSONString(domain));
        }
Beispiel #2
0
        private IMessage PerformPut(IMessage request)
        {
            ISpace ts = this.repository.GetSpace(request.Target);

            if (ts != null)
            {
                PutRequest putReq = (PutRequest)request;
                ts.Put(new Objects.Space.Tuple(putReq.Tuple));
                return(new PutResponse(request.Source, request.Session, request.Target, StatusCode.OK, StatusMessage.OK));
            }
            return(new PutResponse(request.Source, request.Session, request.Target, StatusCode.NOT_FOUND, StatusMessage.NOT_FOUND));
        }
Beispiel #3
0
        /// <summary>
        /// Creates a new lobby in the given space
        /// </summary>
        public Lobby(ISpace space, string lobbyId, uint creatorId, string creatorName, string url)
        {
            this.space  = space;
            Id          = lobbyId;
            CreatorName = creatorName;
            CreatorId   = creatorId;
            Url         = url;

            // Add locks
            space.Put("winner-lock");
            space.Put("lobby_lock");

            // Add player slot tuples
            for (int i = 0; i < Settings.LOBBY_SLOTS; i++)
            {
                space.Put("player", 0, "No user");
            }

            // Create controller
            gameDataStreamer = new GameDataStreamer(space);
            finishListener   = new FinishListener(space, GameFinished);
        }
        public static bool Join(string username)
        {
            Console.WriteLine("Validate username");
            ISpace space = Connection.GlobalSpace;

            // Get lock
            space.Get("newuser_lock");
            space.Put("user", username);
            Tuple result = (Tuple)space.Get("connected", typeof(bool), typeof(int));

            if ((bool)result[1])
            {
                Console.WriteLine("Join succesfull");
                Connection.LocalPlayer = new Player((uint)(int)result[2], username);
                space.Put("newuser_lock");
                return(true);
            }
            else
            {
                space.Put("newuser_lock");
                return(false);
            }
        }
        public static void AddClientScoreToServer(int clientScore)
        {
            ISpace space = Connection.Lobby.Space;

            space.Put("score", (int)Connection.LocalPlayer.Id, clientScore);
        }
Beispiel #6
0
        /// <summary>
        /// Creates and uploads a tuple based on a JToken.
        /// </summary>
        /// <param name="serarchParam"></param>
        /// <param name="UpdateID"></param>
        private void UpdatorJToken(JToken serarchParam, string UpdateID)
        {
            var array = ArrayCreator.CreateArray(serarchParam, UpdateID);

            space.Put(array);
        }