145 lines
2.7 KiB
PHP
145 lines
2.7 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: lucas
|
|
* Date: 07/12/17
|
|
* Time: 19:48
|
|
*/
|
|
|
|
namespace api\module;
|
|
|
|
|
|
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);
|
|
|
|
$wsi = new wsinterop("localhost",9998);
|
|
|
|
$wsi->send([
|
|
"operation" => "PostMessage",
|
|
"message" => $message,
|
|
"username" => $username,
|
|
"location" => $location,
|
|
//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,
|
|
"channelType" => "Emergency",
|
|
"channelName" => is_null($URL_0) ? "" : "$URL_0"
|
|
]);
|
|
|
|
$wsi->close();
|
|
|
|
return ["sent" => true];
|
|
//TODO: tout poster dans la BDD
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
} |