add: Interop pour l'envoi de message + upd: Interop pour la connection
This commit is contained in:
parent
602d72f361
commit
63b5c3afa8
|
@ -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;
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: lucas
|
||||
* Date: 07/12/17
|
||||
* Time: 19:48
|
||||
*/
|
||||
|
||||
namespace api\module;
|
||||
|
||||
|
||||
use kwebsocket\core\wsinterop;
|
||||
|
||||
class message
|
||||
{
|
||||
|
||||
public function POST_emergency($argv){
|
||||
extract($argv);
|
||||
|
||||
$wsi = new wsinterop("localhost",9997);
|
||||
|
||||
$wsi->send([
|
||||
"operation" => "PostMessage",
|
||||
"message" => $message,
|
||||
"username" => $username,
|
||||
"channelType" => "Emergency",
|
||||
"channelName" => $URL_0
|
||||
]);
|
||||
|
||||
return ["sent" => true];
|
||||
//TODO: tout poster dans la BDD
|
||||
}
|
||||
|
||||
}
|
|
@ -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 )
|
||||
|
|
|
@ -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<float>"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"RESTexample": {
|
||||
"POST article": {
|
||||
|
|
Loading…
Reference in New Issue