upd: api.message (UPT message/emergency)
This commit is contained in:
parent
741656e6f1
commit
044abf22e4
|
@ -119,20 +119,35 @@ class message
|
||||||
public function PUT_emergency($argv){
|
public function PUT_emergency($argv){
|
||||||
extract($argv);
|
extract($argv);
|
||||||
|
|
||||||
|
/* (1) Create emergenct
|
||||||
|
---------------------------------------------------------*/
|
||||||
|
/* (1) Try to create entry */
|
||||||
|
$updated = Repo::request('emergency', 'update', $id, $message);
|
||||||
|
|
||||||
|
/* (2) If cannot create -> dispatch error */
|
||||||
|
if( $updated === false )
|
||||||
|
return ['error' => new Error(Err::RepoError)];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* (2) Send to WebSocket
|
||||||
|
---------------------------------------------------------*/
|
||||||
|
/* (1) Create socket */
|
||||||
$wsi = new wsinterop("localhost",9998);
|
$wsi = new wsinterop("localhost",9998);
|
||||||
|
|
||||||
|
/* (2) Send data */
|
||||||
$wsi->send([
|
$wsi->send([
|
||||||
"operation" => "UpdMessage",
|
"operation" => "UpdMessage",
|
||||||
"id" => $id,
|
"id" => "$id",
|
||||||
"message" => $message,
|
"message" => $message,
|
||||||
"channelType" => "Emergency",
|
"channelType" => "Emergency",
|
||||||
"channelName" => is_null($URL_0) ? "" : "$URL_0"
|
"channelName" => "$URL_0"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
/* (3) Close socket */
|
||||||
$wsi->close();
|
$wsi->close();
|
||||||
|
|
||||||
return ["sent" => true];
|
return ['updated' => true];
|
||||||
//TODO: tout poster dans la BDD
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function POST_event($argv){
|
public function POST_event($argv){
|
||||||
|
|
Loading…
Reference in New Issue