Protocole » History » Version 6
Greg Burri, 03/22/2015 10:29 PM
| 1 | 1 | Greg Burri | h1. Protocole |
|---|---|---|---|
| 2 | |||
| 3 | h2. Introduction |
||
| 4 | |||
| 5 | Ce document a pour but de décrire la communication client-serveur du site euphorik. |
||
| 6 | Les messages échangés sont basés sur le format JSON. |
||
| 7 | Ce document remplace 'protocole2.txt'. |
||
| 8 | |||
| 9 | |||
| 10 | h2. Principes |
||
| 11 | |||
| 12 | h3. Enregistrement: |
||
| 13 | |||
| 14 | * Permet de créer un compte, un cookie est donné en retour. Ce cookie doit être stocké par le client pour pouvoir s'authentifier par la suite. |
||
| 15 | |||
| 16 | |||
| 17 | h3. Authentification: |
||
| 18 | |||
| 19 | * L'authentification (login) se fait soit par un couple <login, mot de passe> soit à l'aide d'un cookie. |
||
| 20 | * Permet de récupérer les données d'un profile |
||
| 21 | |||
| 22 | |||
| 23 | h3. Rafraichissement: |
||
| 24 | |||
| 25 | * Le client envoie une demande au serveur avec l'id du dernier message (via XMLHttpRequest ou un function de JQuery) |
||
| 26 | * Le serveur maintient la connexion bloquée si le client est à jour. |
||
| 27 | * Dès qu'un nouveau message arrive, le serveur débloque la connexion et envoie le ou les messages manquants. |
||
| 28 | |||
| 29 | |||
| 30 | 2 | Greg Burri | h2. Messages |
| 31 | 1 | Greg Burri | |
| 32 | <pre> |
||
| 33 | c : client |
||
| 34 | s : server |
||
| 35 | </pre> |
||
| 36 | Les messages client vers serveur sont envoyés par HTTP-POST. |
||
| 37 | |||
| 38 | A toutes les requêtes le serveur peut répondre une erreur : |
||
| 39 | <pre> |
||
| 40 | <error> |
||
| 41 | 2 | Greg Burri | { |
| 42 | "reply" : "error", |
||
| 43 | "no" : 12 |
||
| 44 | "error_message" : "blabla" |
||
| 45 | } |
||
| 46 | 1 | Greg Burri | </pre> |
| 47 | |||
| 48 | Message ok générique : |
||
| 49 | 2 | Greg Burri | <pre> |
| 50 | 1 | Greg Burri | <ok> |
| 51 | { |
||
| 52 | "reply" : "ok" |
||
| 53 | } |
||
| 54 | 2 | Greg Burri | </pre> |
| 55 | 1 | Greg Burri | |
| 56 | 2 | Greg Burri | Entête des messages clients : |
| 57 | 1 | Greg Burri | Si la version du protocole n'est pas similaire du coté serveur la requête est refusée |
| 58 | 2 | Greg Burri | <pre> |
| 59 | 1 | Greg Burri | <client_header> |
| 60 | { |
||
| 61 | "action" : <action>, |
||
| 62 | "version" : 3 |
||
| 63 | } |
||
| 64 | 2 | Greg Burri | </pre> |
| 65 | 1 | Greg Burri | |
| 66 | |||
| 67 | 2 | Greg Burri | h3. Enregistrement et authentification |
| 68 | |||
| 69 | 1 | Greg Burri | Permet de créer un nouvel utilisateur. |
| 70 | "login" et "password" peuvent ne pas être fournis avec un message de type "register", dans ce cas l'utilisateur ne pourra s'authentifier qu'a l'aide de son cookie. |
||
| 71 | Le mot de passe est hashé en md5. |
||
| 72 | |||
| 73 | 2 | Greg Burri | *c -> s* |
| 74 | <pre> |
||
| 75 | 1 | Greg Burri | { |
| 76 | "header" : {action : "register", version : 3}, |
||
| 77 | "login" : "paul", |
||
| 78 | "password" : "IJKJDHHSAD9081238", |
||
| 79 | "profile" : { .. } // voir <profile> |
||
| 80 | } |
||
| 81 | 2 | Greg Burri | </pre> |
| 82 | 1 | Greg Burri | ou |
| 83 | 2 | Greg Burri | <pre> |
| 84 | 1 | Greg Burri | { |
| 85 | "header" : {action : "authentification", version : 3} |
||
| 86 | "cookie" : "LKJDLAKSJBFLKASN" |
||
| 87 | } |
||
| 88 | 2 | Greg Burri | </pre> |
| 89 | 1 | Greg Burri | ou |
| 90 | 2 | Greg Burri | <pre> |
| 91 | 1 | Greg Burri | { |
| 92 | "header" : {action : "authentification", version : 3}, |
||
| 93 | "login" : "paul", |
||
| 94 | "password" : "IJKJDHHSAD9081238" |
||
| 95 | } |
||
| 96 | 2 | Greg Burri | </pre> |
| 97 | 1 | Greg Burri | |
| 98 | 2 | Greg Burri | *s -> c* |
| 99 | <pre> |
||
| 100 | 1 | Greg Burri | { |
| 101 | "reply" : "register" | "authentification", |
||
| 102 | "status" : "auth_registered" | "auth_not_registered", |
||
| 103 | "cookie" : "LKJDLAKSJBFLKASN", |
||
| 104 | "id" : 193, |
||
| 105 | "login" : "paul49", |
||
| 106 | "ek_master" : true | false, |
||
| 107 | "profile" : <profile> |
||
| 108 | } |
||
| 109 | 2 | Greg Burri | </pre> |
| 110 | 1 | Greg Burri | |
| 111 | 2 | Greg Burri | |
| 112 | h3. Logout |
||
| 113 | |||
| 114 | *c -> s* |
||
| 115 | <pre> |
||
| 116 | 1 | Greg Burri | { |
| 117 | "header" : {action : "logout", version : 3}, |
||
| 118 | "cookie" : "LKJDLAKSJBFLKASN" |
||
| 119 | } |
||
| 120 | 2 | Greg Burri | </pre> |
| 121 | |||
| 122 | 1 | Greg Burri | |
| 123 | 2 | Greg Burri | h3. Profile |
| 124 | |||
| 125 | <pre> |
||
| 126 | 1 | Greg Burri | <profile> |
| 127 | { |
||
| 128 | "nick" : "Paul", |
||
| 129 | "email" : "paul@pierre.com", |
||
| 130 | "css" : "css/3/euphorik.css", |
||
| 131 | "chat_order" : "chrono" | "reverse", |
||
| 132 | "nick_format" : "nick" | "login" | "nick_login", |
||
| 133 | "view_times" : true | false, |
||
| 134 | "view_tooltips" : true | false, |
||
| 135 | "conversations" : [{"root" : 3, "minimized" : true}, |
||
| 136 | "ostentatious_master" : "invisible" | "light" | "heavy" |
||
| 137 | } |
||
| 138 | 2 | Greg Burri | </pre> |
| 139 | 1 | Greg Burri | |
| 140 | 2 | Greg Burri | *c -> s* |
| 141 | <pre> |
||
| 142 | 1 | Greg Burri | { |
| 143 | "header" : {action : "set_profile", version : 3}, |
||
| 144 | "cookie" : "LKJDLAKSJBFLKASN", |
||
| 145 | "login" : "paul49", |
||
| 146 | "password" : "IJKJDHHSAD9081238", |
||
| 147 | "profile" : <profile> |
||
| 148 | } |
||
| 149 | 2 | Greg Burri | </pre> |
| 150 | 1 | Greg Burri | |
| 151 | 2 | Greg Burri | *s -> c* |
| 152 | <pre> |
||
| 153 | 1 | Greg Burri | <ok> |
| 154 | ou |
||
| 155 | <error> |
||
| 156 | 2 | Greg Burri | </pre> |
| 157 | 1 | Greg Burri | |
| 158 | |||
| 159 | 2 | Greg Burri | h3. Wait event (page = chat) |
| 160 | |||
| 161 | 1 | Greg Burri | Si "last_message_id" est absent alors le client ne possède pas de message. |
| 162 | Si "main_page" est absent alors est vaut 1. |
||
| 163 | "cookie" n'est pas obligatoire. |
||
| 164 | |||
| 165 | 2 | Greg Burri | <pre> |
| 166 | 1 | Greg Burri | <message> |
| 167 | { |
||
| 168 | "id" : 54, |
||
| 169 | "user_id" : 344, |
||
| 170 | "date" : "Hier 17:26:54", |
||
| 171 | 5 | Greg Burri | "last_update" : "Hier 17:26:54", |
| 172 | 1 | Greg Burri | "system" : true | false, |
| 173 | "owner" : true | false, |
||
| 174 | "answered" : true | false, |
||
| 175 | "is_a_reply" : true | false, |
||
| 176 | "nick" : "Paul", |
||
| 177 | "login" : "paul_22", |
||
| 178 | "content" : "Salut", |
||
| 179 | "root" : 453, |
||
| 180 | "answer_to" : [ |
||
| 181 | { "id" : 123, "nick" : "Pierre", "login" : "pierre_45" } |
||
| 182 | ], |
||
| 183 | "ek_master" : true | false, |
||
| 184 | "ostentatious_master" : "invisible" | "light" | "heavy", |
||
| 185 | "last_modification" : "Hier 17:26:54" |
||
| 186 | } |
||
| 187 | 2 | Greg Burri | </pre> |
| 188 | 1 | Greg Burri | |
| 189 | 2 | Greg Burri | *c -> s* |
| 190 | <pre> |
||
| 191 | 1 | Greg Burri | { |
| 192 | "header" : {action : "wait_event", version : 3}, |
||
| 193 | "page" : "chat" |
||
| 194 | "cookie" : "LKJDLAKSJBFLKASN", |
||
| 195 | "message_count" : 10, |
||
| 196 | "last_message_id" : 163, |
||
| 197 | "main_page" : 1, |
||
| 198 | "conversations" : [ |
||
| 199 | { |
||
| 200 | "root" : 123, |
||
| 201 | "page" : 1, |
||
| 202 | "last_message_id" : 4 (pas obligatoire) |
||
| 203 | } |
||
| 204 | ] |
||
| 205 | } |
||
| 206 | 2 | Greg Burri | </pre> |
| 207 | 1 | Greg Burri | |
| 208 | 2 | Greg Burri | *s -> c* |
| 209 | 1 | Greg Burri | La première conversation est la principale (main). |
| 210 | L'ordre des conversation est le même que celui des données de l'utilisateur. |
||
| 211 | Le format de la date n'est pas formel. |
||
| 212 | first correpond au premier message de la conversation, vaut 'null' pour la conversation principale ainsi que pour les conversations vides. |
||
| 213 | 2 | Greg Burri | <pre> |
| 214 | 1 | Greg Burri | { |
| 215 | "reply" : "new_message", |
||
| 216 | "conversations" : [ |
||
| 217 | { |
||
| 218 | "last_page" : true | false, |
||
| 219 | "first" : <message> | null, |
||
| 220 | "messages" : [ <message>, .. ] |
||
| 221 | } |
||
| 222 | ] |
||
| 223 | } |
||
| 224 | 2 | Greg Burri | </pre> |
| 225 | 1 | Greg Burri | ou |
| 226 | 2 | Greg Burri | <pre> |
| 227 | 1 | Greg Burri | { |
| 228 | "reply" : "message_updated", |
||
| 229 | 5 | Greg Burri | <message> |
| 230 | 1 | Greg Burri | } |
| 231 | 2 | Greg Burri | </pre> |
| 232 | 1 | Greg Burri | ou |
| 233 | 2 | Greg Burri | <pre> |
| 234 | 1 | Greg Burri | <error> |
| 235 | </pre> |
||
| 236 | 2 | Greg Burri | |
| 237 | 1 | Greg Burri | |
| 238 | h3. Wait event (page = admin) |
||
| 239 | 2 | Greg Burri | |
| 240 | *c -> s* |
||
| 241 | <pre> |
||
| 242 | { |
||
| 243 | 1 | Greg Burri | "header" : {action : "wait_event", version : 3}, |
| 244 | 6 | Greg Burri | "page" : "admin" |
| 245 | 1 | Greg Burri | } |
| 246 | 2 | Greg Burri | </pre> |
| 247 | 1 | Greg Burri | |
| 248 | indique de mettre à jour la liste d'ips |
||
| 249 | 2 | Greg Burri | *s -> c* |
| 250 | <pre> |
||
| 251 | 1 | Greg Burri | { |
| 252 | "reply" : "banned_ips_refresh" |
||
| 253 | } |
||
| 254 | 2 | Greg Burri | </pre> |
| 255 | 1 | Greg Burri | |
| 256 | |||
| 257 | 2 | Greg Burri | h3. Envoie message |
| 258 | |||
| 259 | 1 | Greg Burri | Le client envoie un message, le message peut répondre à un certain nombre d'autres messages. |
| 260 | "answer_to" n'est pas obligatoire. |
||
| 261 | |||
| 262 | 2 | Greg Burri | *c -> s* |
| 263 | <pre> |
||
| 264 | 1 | Greg Burri | { |
| 265 | "header" : {action : "put_message", version : 3}, |
||
| 266 | "cookie" : "LKJDLAKSJBFLKASN", |
||
| 267 | "nick" : "Paul", |
||
| 268 | "content" : "Bonjour", |
||
| 269 | "answer_to" : [ 345, 532, ... ] |
||
| 270 | } |
||
| 271 | 2 | Greg Burri | </pre> |
| 272 | 1 | Greg Burri | |
| 273 | 2 | Greg Burri | *s -> c* |
| 274 | <pre> |
||
| 275 | 1 | Greg Burri | <ok> |
| 276 | 2 | Greg Burri | </pre> |
| 277 | 1 | Greg Burri | ou |
| 278 | 2 | Greg Burri | <pre> |
| 279 | 1 | Greg Burri | <error> |
| 280 | 2 | Greg Burri | </pre> |
| 281 | 1 | Greg Burri | |
| 282 | |||
| 283 | 2 | Greg Burri | h3. Slapage |
| 284 | |||
| 285 | *c -> s* |
||
| 286 | <pre> |
||
| 287 | 1 | Greg Burri | { |
| 288 | "header" : {action : "slap", version : 3}, |
||
| 289 | "cookie" : "LKJDLAKSJBFLKASN", |
||
| 290 | "user_id" : 67, |
||
| 291 | "reason" : "blablabla" |
||
| 292 | } |
||
| 293 | 2 | Greg Burri | </pre> |
| 294 | 1 | Greg Burri | |
| 295 | 2 | Greg Burri | |
| 296 | *s -> c* |
||
| 297 | <pre> |
||
| 298 | 1 | Greg Burri | <ok> |
| 299 | 2 | Greg Burri | </pre> |
| 300 | 1 | Greg Burri | ou |
| 301 | 2 | Greg Burri | <pre> |
| 302 | 1 | Greg Burri | <error> |
| 303 | 2 | Greg Burri | </pre> |
| 304 | 1 | Greg Burri | |
| 305 | |||
| 306 | 2 | Greg Burri | h3. Bannissement |
| 307 | |||
| 308 | *c -> s* |
||
| 309 | <pre> |
||
| 310 | 1 | Greg Burri | { |
| 311 | "header" : {action : "ban", version : 3}, |
||
| 312 | "cookie" : "LKJDLAKSJBFLKASN", |
||
| 313 | "duration" : 15, // en minute |
||
| 314 | "user_id" : 67, |
||
| 315 | "reason" : "blablabla" |
||
| 316 | } |
||
| 317 | 2 | Greg Burri | </pre> |
| 318 | 1 | Greg Burri | |
| 319 | 2 | Greg Burri | |
| 320 | *s -> c* |
||
| 321 | <pre> |
||
| 322 | 1 | Greg Burri | <ok> |
| 323 | 2 | Greg Burri | </pre> |
| 324 | 1 | Greg Burri | ou |
| 325 | 2 | Greg Burri | <pre> |
| 326 | 1 | Greg Burri | <error> |
| 327 | 2 | Greg Burri | </pre> |
| 328 | 1 | Greg Burri | |
| 329 | |||
| 330 | 2 | Greg Burri | h3. Liste des ip bannis |
| 331 | |||
| 332 | *c -> s* |
||
| 333 | <pre> |
||
| 334 | 1 | Greg Burri | { |
| 335 | "header" : {action : "list_banned_ips", version : 3}, |
||
| 336 | "cookie" : "LKJDLAKSJBFLKASN" |
||
| 337 | } |
||
| 338 | 2 | Greg Burri | </pre> |
| 339 | 1 | Greg Burri | |
| 340 | 2 | Greg Burri | *s -> c* |
| 341 | <pre> |
||
| 342 | 1 | Greg Burri | { |
| 343 | "reply" : "list_banned_ips", |
||
| 344 | "list" : [ |
||
| 345 | { |
||
| 346 | ip : "192.168.1.2", |
||
| 347 | remaining_time : "1h23" |
||
| 348 | users : [ |
||
| 349 | { |
||
| 350 | nick : "Pierre" , |
||
| 351 | login : "pierre" |
||
| 352 | } |
||
| 353 | ] |
||
| 354 | } |
||
| 355 | ] |
||
| 356 | } |
||
| 357 | 2 | Greg Burri | </pre> |
| 358 | 1 | Greg Burri | |
| 359 | 2 | Greg Burri | h3. Débannissement |
| 360 | |||
| 361 | *c -> s* |
||
| 362 | <pre> |
||
| 363 | 1 | Greg Burri | { |
| 364 | "header" : {action : "unban", version : 3}, |
||
| 365 | "cookie" : "LKJDLAKSJBFLKASN" |
||
| 366 | "ip" : "192.168.1.2" |
||
| 367 | } |
||
| 368 | 2 | Greg Burri | </pre> |
| 369 | |||
| 370 | *s -> c* |
||
| 371 | <pre> |
||
| 372 | 1 | Greg Burri | <ok> |
| 373 | 2 | Greg Burri | </pre> |
| 374 | 1 | Greg Burri | ou |
| 375 | 2 | Greg Burri | <pre> |
| 376 | 1 | Greg Burri | <error> |
| 377 | 2 | Greg Burri | </pre> |
| 378 | 1 | Greg Burri | |
| 379 | |||
| 380 | 2 | Greg Burri | h3. Ajout d'une correction d'un messages |
| 381 | |||
| 382 | _(non implémenté, améliorer pour la modification complète d'un message)_ |
||
| 383 | 1 | Greg Burri | Le client envoie un correctif sous la forme de texte supplémentaire à appondre au dernier messages. |
| 384 | Le message est appondu avec un " +++ " devant, par exemple : |
||
| 385 | 4 | Greg Burri | <pre> |
| 386 | Gnome c'est mieux que KDE +++ Euh non ok, c'est faux |
||
| 387 | </pre> |
||
| 388 | 1 | Greg Burri | |
| 389 | 3 | Greg Burri | *c -> s* |
| 390 | <pre> |
||
| 391 | 1 | Greg Burri | { |
| 392 | "header" : {action : "correction", version : 3}, |
||
| 393 | "cookie" : "LKJDLAKSJBFLKASN", |
||
| 394 | "content" : "Euh non ok, c'est faux" |
||
| 395 | } |
||
| 396 | 3 | Greg Burri | </pre> |
| 397 | |||
| 398 | *s -> c* |
||
| 399 | <pre> |
||
| 400 | 1 | Greg Burri | { |
| 401 | "reply" : "correction", |
||
| 402 | "status" : "ok" | "error", |
||
| 403 | "message_error" : "blabla" |
||
| 404 | } |
||
| 405 | 3 | Greg Burri | </pre> |