Ejemplo n.º 1
0
        public CreateRoomResponse CreateRoom(CreateRoomRequest request)
        {
            CreateRoomResponse response = new CreateRoomResponse();

              rwLock.EnterWriteLock();
              try
              {
            response.Success = !gameLobby.Rooms.ContainsKey(request.GameRoom.Name);
            if(response.Success)
            {
              IPoLServerCallback channel = OperationContext.Current.GetCallbackChannel<IPoLServerCallback>();
              var ply = gameLobby.GetPlayerByChannel(channel);
              gameLobby.Rooms.Add(request.GameRoom.Name, new dm.GameRoom(request.GameRoom.Name, request.GameRoom.Description, ply));
            }
              }
              finally
              {
            rwLock.ExitWriteLock();
              }

              return response;
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var channelFactory = new DuplexChannelFactory<IPoLServer>(new InstanceContext(this), "pol");
              var clientChannel = channelFactory.CreateChannel();

              var enterLobbyReq = new DataContracts.EnterLobbyRequest();
              enterLobbyReq.Player = new DataContracts.Player();
              enterLobbyReq.Player.Name = "Pippo";
              var enterLobbyResp = clientChannel.EnterLobby(enterLobbyReq);

              var createroomReq = new DataContracts.CreateRoomRequest();
              createroomReq.GameRoom = new DataContracts.GameRoom();
              createroomReq.GameRoom.Name = "Room1";
              createroomReq.GameRoom.Description = "desc Room1";
              var createroomResp = clientChannel.CreateRoom(createroomReq);
              createroomReq = new DataContracts.CreateRoomRequest();
              createroomReq.GameRoom = new DataContracts.GameRoom();
              createroomReq.GameRoom.Name = "Room2";
              createroomReq.GameRoom.Description = "desc Room2";
              createroomResp = clientChannel.CreateRoom(createroomReq);
              var getallroomsReq = new DataContracts.GetAllRoomsRequest();
              var getallroomsResp = clientChannel.GetAllRooms(getallroomsReq);
        }