Compare commits

...

1 Commits

Author SHA1 Message Date
SeekDaSky 41d3dcf8c3 add: Interop pour le channel event 2017-12-08 01:56:21 +01:00
2 changed files with 154 additions and 0 deletions

View File

@ -14,6 +14,15 @@ 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);
@ -73,4 +82,64 @@ class message
//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
}
}

View File

@ -156,6 +156,91 @@
"optional": false
}
}
},
"GET emergency": {
"description" : "",
"permissions": [],
"parameters": {
"URL_0": {
"description": "code departement, si le paramètre n'est pas fourni le message est envoyé en broadcast",
"type" : "numeric",
"optional" : false
},
"limit":{
"description": "nombre de message a récupérer maximum",
"type" : "numeric",
"optional": true
}
}
},
"POST event": {
"description" : "",
"permissions": [],
"parameters": {
"URL_0": {
"description": "code departement, si le paramètre n'est pas fourni le message est envoyé en broadcast",
"type" : "numeric",
"optional" : true
},
"message": {
"description": "message a publier",
"type": "text",
"optional": false
},
"username": {
"description": "username affiché dans le channel",
"type": "varchar(3,20)",
"optional": false
},
"type": {
"description": "Flag du type d'evenement",
"type": "numeric"
},
"location": {
"description": "coordonés GPS du message, des coordonnées invalide ne seront pas affiché",
"type": "array<numeric>"
}
}
},
"DELETE event": {
"description": "",
"permissions": [],
"parameters": {
"URL_0": {
"description": "code departement, si le paramètre n'est pas fourni le message est envoyé en broadcast",
"type": "numeric",
"optional": true
},
"id": {
"description": "message a publier",
"type": "text"
}
}
},
"PUT event": {
"description" : "",
"permissions": [],
"parameters": {
"URL_0": {
"description": "code departement, si le paramètre n'est pas fourni le message est envoyé en broadcast",
"type" : "numeric",
"optional" : true
},
"id": {
"description": "message a publier",
"type": "text"
},
"message": {
"description": "message a publier",
"type": "text",
"optional": false
}
}
}
},