upd: api.message (UPT message/emergency)

This commit is contained in:
xdrm-brackets 2017-12-08 04:30:43 +01:00
parent 741656e6f1
commit 044abf22e4
1 changed files with 21 additions and 6 deletions

View File

@ -119,20 +119,35 @@ class message
public function PUT_emergency($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);
/* (2) Send data */
$wsi->send([
"operation" => "UpdMessage",
"id" => $id,
"message" => $message,
"operation" => "UpdMessage",
"id" => "$id",
"message" => $message,
"channelType" => "Emergency",
"channelName" => is_null($URL_0) ? "" : "$URL_0"
"channelName" => "$URL_0"
]);
/* (3) Close socket */
$wsi->close();
return ["sent" => true];
//TODO: tout poster dans la BDD
return ['updated' => true];
}
public function POST_event($argv){