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": {