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){ 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){