From 63b5c3afa8529e8046ba6c4f833ce2713093cb86 Mon Sep 17 00:00:00 2001 From: SeekDaSky Date: Thu, 7 Dec 2017 20:24:59 +0100 Subject: [PATCH] add: Interop pour l'envoi de message + upd: Interop pour la connection --- build/api/core/Checker.php | 4 ++++ build/api/module/message.php | 34 ++++++++++++++++++++++++++++++++ build/router/controller/page.php | 6 +++--- config/modules.json | 29 +++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 build/api/module/message.php diff --git a/build/api/core/Checker.php b/build/api/core/Checker.php index 19880d0..02d631b 100755 --- a/build/api/core/Checker.php +++ b/build/api/core/Checker.php @@ -141,6 +141,10 @@ return $checker && (is_numeric($value) || $value == null || $value == 'null'); break; + case "float": + return $checker && is_float($value); + break; + default: return false; break; diff --git a/build/api/module/message.php b/build/api/module/message.php new file mode 100644 index 0000000..d0f103d --- /dev/null +++ b/build/api/module/message.php @@ -0,0 +1,34 @@ +send([ + "operation" => "PostMessage", + "message" => $message, + "username" => $username, + "channelType" => "Emergency", + "channelName" => $URL_0 + ]); + + return ["sent" => true]; + //TODO: tout poster dans la BDD + } + +} \ No newline at end of file diff --git a/build/router/controller/page.php b/build/router/controller/page.php index 00339d2..ac1668c 100755 --- a/build/router/controller/page.php +++ b/build/router/controller/page.php @@ -35,7 +35,7 @@ if( count($_SESSION['USER']) > 0 ){ // get/send name to web socket - $wsi->send(['type' => 'user', 'name' => $_SESSION['USER']['username']]); + $wsi->send(['operation' => "Connect",'type' => 'user', 'name' => $_SESSION['USER']['username']]); $check = $wsi->receive(); if( $check['error'] == false ) @@ -44,7 +44,7 @@ }elseif( count($_SESSION['ADMIN']) > 0 ){ // get/send name to web socket - $wsi->send(['type' => 'admin', 'name' => $_SESSION['ADMIN']['username']]); + $wsi->send(['operation' => "Connect",'type' => 'admin', 'name' => $_SESSION['ADMIN']['username']]); $check = $wsi->receive(); if( $check['error'] == false ) @@ -53,7 +53,7 @@ }else{ // get/send name to web socket - $wsi->send(['type' => 'guest', 'name' => null]); + $wsi->send(['operation' => "Connect",'type' => 'guest', 'name' => null]); $check = $wsi->receive(); if( $check['error'] == false ) diff --git a/config/modules.json b/config/modules.json index 01e3631..852f7c0 100755 --- a/config/modules.json +++ b/config/modules.json @@ -101,7 +101,36 @@ }, + "message": { + "POST emergency": { + "description" : "", + "permissions": [], + "parameters": { + "URL_0": { + "description": "code departement, si le paramètre n'est pas fourni le message est envoyé en broadcast", + "type" : "varchar(2,2)", + "optional" : true + }, + "message": { + "description": "message a publier", + "type": "text", + "optional": false + }, + + "username": { + "description": "username affiché dans le channel", + "type": "varchar(3,20)", + "optional": false + }, + + "location": { + "description": "coordonés GPS du message, des coordonnées invalide ne seront pas affiché", + "type": "array" + } + } + } + }, "RESTexample": { "POST article": {