redirectToRoute( 'room_namespace', [ 'namespace' => $this->getParameter('app.kevacoin.namespace') ] ); } #[Route( '/room/{namespace}', name: 'room_namespace', requirements: [ 'namespace' => '^[A-z0-9]{34}$', ], methods: [ 'GET' ] )] public function room( Request $request ): Response { // Connect kevacoin $client = new \Kevachat\Kevacoin\Client( $this->getParameter('app.kevacoin.protocol'), $this->getParameter('app.kevacoin.host'), $this->getParameter('app.kevacoin.port'), $this->getParameter('app.kevacoin.username'), $this->getParameter('app.kevacoin.password') ); // Get room posts $posts = []; foreach ((array) $client->kevaFilter($request->get('namespace')) as $message) { $posts[] = [ 'key' => $message['key'], 'value' => $message['value'], 'height' => $message['height'], 'vout' => $message['vout'], 'txid' => $message['txid'], ]; } // Return result return $this->render( 'default/room/index.html.twig', [ 'posts' => $posts, 'request' => $request ] ); } #[Route( '/room/{namespace}/post', name: 'room_post', requirements: [ 'namespace' => '^[A-z0-9]{34}$', ], methods: [ 'POST' ] )] public function post( Request $request ): Response { // Connect kevacoin $client = new \Kevachat\Kevacoin\Client( $this->getParameter('app.kevacoin.protocol'), $this->getParameter('app.kevacoin.host'), $this->getParameter('app.kevacoin.port'), $this->getParameter('app.kevacoin.username'), $this->getParameter('app.kevacoin.password') ); // Check namespace exist for this wallet $namespaces = []; foreach ((array) $client->kevaListNamespaces() as $value) { $namespaces[] = $value['namespaceId']; } if (!in_array($request->get('namespace'), $namespaces)) { exit('Namespace not related with this node!'); } // @TODO // Redirect back to the room return $this->redirectToRoute( 'room_namespace', [ 'namespace' => $this->getParameter('app.kevacoin.namespace') ] ); } }