Пример #1
0
        public void joinGame(int w, int h)
        {
            screenSize = new Size(w, h);

            if (w == 0 || h == 0)
            {
                return;
            }

            lock (waitingRoom)
            {
                if (waitingRoom.Any())
                {
                    otherPlayerId = waitingRoom.First();
                    waitingRoom.Remove(otherPlayerId);
                }
                else
                {
                    waitingRoom.Add(details.ClientId);
                    Log(details.ClientId + " joined to room");
                    return;
                }
            }

            GondorGame gm = null;

            try
            {
                CometWorker.GetClientObject(otherPlayerId, "Server", out gm);
            }catch {}

            if (gm == null)
            {
                Log("Game object for " + otherPlayerId + " not found");
                lock (waitingRoom)
                {
                    waitingRoom.Add(details.ClientId);
                }
                return;
            }

            int[] nums = prepareGame();
            Log(otherPlayerId + " game starts");
            opponentSize    = gm.screenSize;
            gm.opponentSize = screenSize;

            gm.startGame(nums);

            gm.otherPlayerId = details.ClientId;
            startGame(nums);
            Log(details.ClientId + " game starts");
        }
Пример #2
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            Test   test;
            string clientId = this.HiddenField1.Value;

            if (clientId != "")
            {
                //get the pokein instance
                CometWorker.GetClientObject <Test>(clientId, "Test", out test);

                //call pokein method of this instance
                test.GetTime();
            }
        }