2017-12-07 19:24:59 +00:00
|
|
|
<?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);
|
|
|
|
|
2017-12-07 20:06:09 +00:00
|
|
|
$wsi = new wsinterop("localhost",9998);
|
2017-12-07 19:24:59 +00:00
|
|
|
|
|
|
|
$wsi->send([
|
|
|
|
"operation" => "PostMessage",
|
|
|
|
"message" => $message,
|
|
|
|
"username" => $username,
|
2017-12-07 20:06:09 +00:00
|
|
|
"location" => $location,
|
2017-12-07 22:40:05 +00:00
|
|
|
//TODO implémenter la récupération d'id depuis la bdd
|
|
|
|
"id" => uniqid(),
|
|
|
|
"channelType" => "Emergency",
|
|
|
|
"channelName" => is_null($URL_0) ? "" : "$URL_0"
|
|
|
|
]);
|
|
|
|
|
|
|
|
$wsi->close();
|
|
|
|
|
|
|
|
return ["sent" => true];
|
|
|
|
//TODO: tout poster dans la BDD
|
|
|
|
}
|
|
|
|
|
|
|
|
public function DELETE_emergency($argv){
|
|
|
|
extract($argv);
|
|
|
|
|
|
|
|
$wsi = new wsinterop("localhost",9998);
|
|
|
|
|
|
|
|
$wsi->send([
|
|
|
|
"operation" => "DelMessage",
|
|
|
|
"id" => $id,
|
2017-12-07 19:24:59 +00:00
|
|
|
"channelType" => "Emergency",
|
2017-12-07 20:06:09 +00:00
|
|
|
"channelName" => is_null($URL_0) ? "" : "$URL_0"
|
2017-12-07 19:24:59 +00:00
|
|
|
]);
|
|
|
|
|
2017-12-07 20:06:09 +00:00
|
|
|
$wsi->close();
|
|
|
|
|
2017-12-07 19:24:59 +00:00
|
|
|
return ["sent" => true];
|
|
|
|
//TODO: tout poster dans la BDD
|
|
|
|
}
|
|
|
|
|
2017-12-07 23:43:58 +00:00
|
|
|
public function PUT_emergency($argv){
|
|
|
|
extract($argv);
|
|
|
|
|
|
|
|
$wsi = new wsinterop("localhost",9998);
|
|
|
|
|
|
|
|
$wsi->send([
|
|
|
|
"operation" => "UpdMessage",
|
|
|
|
"id" => $id,
|
|
|
|
"message" => $message,
|
|
|
|
"channelType" => "Emergency",
|
|
|
|
"channelName" => is_null($URL_0) ? "" : "$URL_0"
|
|
|
|
]);
|
|
|
|
|
|
|
|
$wsi->close();
|
|
|
|
|
|
|
|
return ["sent" => true];
|
|
|
|
//TODO: tout poster dans la BDD
|
|
|
|
}
|
|
|
|
|
2017-12-07 19:24:59 +00:00
|
|
|
}
|