~ucl-cs-study-devs/study.cs.ucl-websites/password-trunk

« back to all changes in this revision

Viewing changes to src/UCL/StudyBundle/Controller/AppPartController.php

  • Committer: Steve DODIER-LAZARO
  • Date: 2015-09-25 14:11:08 UTC
  • Revision ID: sdodierl@secdev.cs.ucl.ac.uk-20150925141108-kj5tmh4bgsvp2vtu
Adding a RPC action to the App part controller for RabbitMQ responses to the chrome client

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
use UCL\StudyBundle\Controller\UCLStudyController as UCLStudyController;
11
11
use UCL\StudyBundle\Form\Type\DataUploadType;
12
12
use UCL\StudyBundle\Entity\DataUploadJob;
 
13
use PhpAmqpLib\Message\AMQPMessage;
 
14
use PhpAmqpLib\Connection\AMQPConnection;
 
15
#use UCL\StudyBundle\Controller\ConnectionHandler;
13
16
#use UCL\StudyBundle\Entity\Participant;
14
17
#use UCL\StudyBundle\Entity\StepProgress;
15
18
 
461
464
    {
462
465
      return $this->forward('UCLStudyBundle:StudyPart:infosheet', array('_part' => $_part, 'request' => $request));
463
466
    }
 
467
 
 
468
    /**
 
469
     *@Route("/a/rpc", name="ucl_study_rpc_dispatcher_rabbitmq")
 
470
     */
 
471
    public function rpcAction(Request $request)
 
472
    {
 
473
      $content = $this->get("request")->getContent();
 
474
      if (!empty($content))
 
475
      {
 
476
          $conn = $this->get("rabbit_connection");
 
477
 
 
478
          $data = json_decode($content);
 
479
          $data = $content;
 
480
 
 
481
          $ret = $conn->call($data);
 
482
 
 
483
          return new Response($ret);
 
484
      }
 
485
 
 
486
      return new Response('Done');  
 
487
    }
 
488
 
464
489
}
 
490