From f3437d8db91ee2ecdf227ed635d609358d39a69c Mon Sep 17 00:00:00 2001 From: SeekDaSky Date: Fri, 8 Dec 2017 01:56:21 +0100 Subject: [PATCH] add: Interop pour le channel event --- build/api/module/message.php | 69 +++++++++++++++++++++++++++++ config/modules.json | 85 ++++++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+) diff --git a/build/api/module/message.php b/build/api/module/message.php index ddc9bc1..69e6323 100644 --- a/build/api/module/message.php +++ b/build/api/module/message.php @@ -14,6 +14,15 @@ use kwebsocket\core\wsinterop; class message { + public function GET_emergency($argv){ + extract($argv); + + $messages = []; + + return ["sent" => true, "messages" => $messages]; + //TODO: tout poster dans la BDD + } + public function POST_emergency($argv){ extract($argv); @@ -73,4 +82,64 @@ class message //TODO: tout poster dans la BDD } + public function POST_event($argv){ + extract($argv); + + $wsi = new wsinterop("localhost",9998); + + $wsi->send([ + "operation" => "PostMessage", + "message" => $message, + "username" => $username, + "location" => $location, + "type" => $type, + //TODO implémenter la récupération d'id depuis la bdd + "id" => uniqid(), + "channelType" => "Event", + "channelName" => is_null($URL_0) ? "" : "$URL_0" + ]); + + $wsi->close(); + + return ["sent" => true]; + //TODO: tout poster dans la BDD + } + + public function DELETE_event($argv){ + extract($argv); + + $wsi = new wsinterop("localhost",9998); + + $wsi->send([ + "operation" => "DelMessage", + "id" => $id, + "channelType" => "Event", + "channelName" => is_null($URL_0) ? "" : "$URL_0" + ]); + + $wsi->close(); + + return ["sent" => true]; + //TODO: tout poster dans la BDD + } + + public function PUT_event($argv){ + extract($argv); + + $wsi = new wsinterop("localhost",9998); + + $wsi->send([ + "operation" => "UpdMessage", + "id" => $id, + "message" => $message, + "channelType" => "Event", + "channelName" => is_null($URL_0) ? "" : "$URL_0" + ]); + + $wsi->close(); + + return ["sent" => true]; + //TODO: tout poster dans la BDD + } + } \ No newline at end of file diff --git a/config/modules.json b/config/modules.json index 4b1f7f5..8a3415c 100755 --- a/config/modules.json +++ b/config/modules.json @@ -156,6 +156,91 @@ "optional": false } } + }, + "GET emergency": { + "description" : "", + "permissions": [], + "parameters": { + "URL_0": { + "description": "code departement, si le paramètre n'est pas fourni le message est envoyé en broadcast", + "type" : "numeric", + "optional" : false + }, + "limit":{ + "description": "nombre de message a récupérer maximum", + "type" : "numeric", + "optional": true + } + } + }, + + "POST event": { + "description" : "", + "permissions": [], + "parameters": { + "URL_0": { + "description": "code departement, si le paramètre n'est pas fourni le message est envoyé en broadcast", + "type" : "numeric", + "optional" : true + }, + + "message": { + "description": "message a publier", + "type": "text", + "optional": false + }, + + "username": { + "description": "username affiché dans le channel", + "type": "varchar(3,20)", + "optional": false + }, + + "type": { + "description": "Flag du type d'evenement", + "type": "numeric" + }, + + "location": { + "description": "coordonés GPS du message, des coordonnées invalide ne seront pas affiché", + "type": "array" + } + } + }, + "DELETE event": { + "description": "", + "permissions": [], + "parameters": { + "URL_0": { + "description": "code departement, si le paramètre n'est pas fourni le message est envoyé en broadcast", + "type": "numeric", + "optional": true + }, + "id": { + "description": "message a publier", + "type": "text" + } + } + }, + "PUT event": { + "description" : "", + "permissions": [], + "parameters": { + "URL_0": { + "description": "code departement, si le paramètre n'est pas fourni le message est envoyé en broadcast", + "type" : "numeric", + "optional" : true + }, + "id": { + "description": "message a publier", + "type": "text" + }, + "message": { + "description": "message a publier", + "type": "text", + "optional": false + } + } } },