Protocole » History » Version 3
Greg Burri, 07/28/2008 10:46 AM
| 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 | "system" : true | false, |
||
| 172 | "owner" : true | false, |
||
| 173 | "answered" : true | false, |
||
| 174 | "is_a_reply" : true | false, |
||
| 175 | "nick" : "Paul", |
||
| 176 | "login" : "paul_22", |
||
| 177 | "content" : "Salut", |
||
| 178 | "root" : 453, |
||
| 179 | "answer_to" : [ |
||
| 180 | { "id" : 123, "nick" : "Pierre", "login" : "pierre_45" } |
||
| 181 | ], |
||
| 182 | "ek_master" : true | false, |
||
| 183 | "ostentatious_master" : "invisible" | "light" | "heavy", |
||
| 184 | "last_modification" : "Hier 17:26:54" |
||
| 185 | } |
||
| 186 | 2 | Greg Burri | </pre> |
| 187 | 1 | Greg Burri | |
| 188 | 2 | Greg Burri | *c -> s* |
| 189 | <pre> |
||
| 190 | 1 | Greg Burri | { |
| 191 | "header" : {action : "wait_event", version : 3}, |
||
| 192 | "page" : "chat" |
||
| 193 | "cookie" : "LKJDLAKSJBFLKASN", |
||
| 194 | "message_count" : 10, |
||
| 195 | "last_message_id" : 163, |
||
| 196 | "main_page" : 1, |
||
| 197 | "troll_id" : 45, |
||
| 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 | "message_id" : 123, |
||
| 230 | "content" : "Salut poulpe", |
||
| 231 | "last_modification" : "Hier 17:26:54" |
||
| 232 | } |
||
| 233 | 2 | Greg Burri | </pre> |
| 234 | 1 | Greg Burri | ou |
| 235 | 2 | Greg Burri | <pre> |
| 236 | 1 | Greg Burri | { |
| 237 | "reply" : "new_troll", |
||
| 238 | "troll_id" : 123, |
||
| 239 | "message_id" : 12, |
||
| 240 | "content" : "Linux sera desktop ready en 2008 ?" |
||
| 241 | } |
||
| 242 | 2 | Greg Burri | </pre> |
| 243 | 1 | Greg Burri | ou |
| 244 | 2 | Greg Burri | <pre> |
| 245 | 1 | Greg Burri | <error> |
| 246 | 2 | Greg Burri | </pre> |
| 247 | 1 | Greg Burri | |
| 248 | |||
| 249 | 2 | Greg Burri | h3. Wait event (page = admin) |
| 250 | |||
| 251 | *c -> s* |
||
| 252 | <pre> |
||
| 253 | 1 | Greg Burri | { |
| 254 | "header" : {action : "wait_event", version : 3}, |
||
| 255 | "page" : "admin", |
||
| 256 | "last_troll" : 5 |
||
| 257 | } |
||
| 258 | 2 | Greg Burri | </pre> |
| 259 | 1 | Greg Burri | |
| 260 | 2 | Greg Burri | *s -> c* |
| 261 | <pre> |
||
| 262 | 1 | Greg Burri | { |
| 263 | "reply" : "troll_modified", |
||
| 264 | "troll_id" : 3, |
||
| 265 | "content" : "plop" |
||
| 266 | } |
||
| 267 | 2 | Greg Burri | </pre> |
| 268 | 1 | Greg Burri | ou |
| 269 | 2 | Greg Burri | *s -> c* |
| 270 | <pre> |
||
| 271 | 1 | Greg Burri | { |
| 272 | "reply" : "troll_added", |
||
| 273 | "trolls" : |
||
| 274 | [ |
||
| 275 | { |
||
| 276 | "troll_id" : 5, |
||
| 277 | "content" : "plop", |
||
| 278 | "author" : "<Pseudo>" |
||
| 279 | "author_id" : 2 |
||
| 280 | } |
||
| 281 | ] |
||
| 282 | } |
||
| 283 | 2 | Greg Burri | </pre> |
| 284 | 1 | Greg Burri | ou |
| 285 | 2 | Greg Burri | *s -> c* |
| 286 | <pre> |
||
| 287 | 1 | Greg Burri | { |
| 288 | "reply" : "troll_deleted", |
||
| 289 | "troll_id" : 2 |
||
| 290 | } |
||
| 291 | 2 | Greg Burri | </pre> |
| 292 | 1 | Greg Burri | ou |
| 293 | indique de mettre à jour la liste d'ips |
||
| 294 | 2 | Greg Burri | *s -> c* |
| 295 | <pre> |
||
| 296 | 1 | Greg Burri | { |
| 297 | "reply" : "banned_ips_refresh" |
||
| 298 | } |
||
| 299 | 2 | Greg Burri | </pre> |
| 300 | 1 | Greg Burri | |
| 301 | |||
| 302 | 2 | Greg Burri | h3. Envoie d'un troll |
| 303 | |||
| 304 | *c -> s* |
||
| 305 | <pre> |
||
| 306 | 1 | Greg Burri | { |
| 307 | "header" : {action : "put_troll", version : 3}, |
||
| 308 | "cookie" : "LKJDLAKSJBFLKASN", |
||
| 309 | "content" : "Un bon troll velu !" |
||
| 310 | } |
||
| 311 | 2 | Greg Burri | </pre> |
| 312 | |||
| 313 | *s -> c* |
||
| 314 | <pre> |
||
| 315 | 1 | Greg Burri | <ok> |
| 316 | 2 | Greg Burri | </pre> |
| 317 | 1 | Greg Burri | ou |
| 318 | 2 | Greg Burri | <pre> |
| 319 | 1 | Greg Burri | <error> |
| 320 | 2 | Greg Burri | </pre> |
| 321 | 1 | Greg Burri | |
| 322 | |||
| 323 | 2 | Greg Burri | h3. Modification d'un troll |
| 324 | |||
| 325 | *c -> s* |
||
| 326 | <pre> |
||
| 327 | 1 | Greg Burri | { |
| 328 | "header" : {action : "mod_troll", version : 3}, |
||
| 329 | "cookie" : "LKJDLAKSJBFLKASN", |
||
| 330 | "troll_id" : 3, |
||
| 331 | "content" : "Un bon troll velu 2 !" |
||
| 332 | } |
||
| 333 | 2 | Greg Burri | </pre> |
| 334 | |||
| 335 | *s -> c* |
||
| 336 | <pre> |
||
| 337 | 1 | Greg Burri | <ok> |
| 338 | 2 | Greg Burri | </pre> |
| 339 | 1 | Greg Burri | ou |
| 340 | 2 | Greg Burri | <pre> |
| 341 | 1 | Greg Burri | <error> |
| 342 | 2 | Greg Burri | </pre> |
| 343 | 1 | Greg Burri | |
| 344 | |||
| 345 | 2 | Greg Burri | h3. Suppression d'un troll |
| 346 | |||
| 347 | *c -> s* |
||
| 348 | <pre> |
||
| 349 | 1 | Greg Burri | { |
| 350 | "header" : {action : "del_troll", version : 3}, |
||
| 351 | "cookie" : "LKJDLAKSJBFLKASN", |
||
| 352 | "troll_id" : 3 |
||
| 353 | } |
||
| 354 | 2 | Greg Burri | </pre> |
| 355 | 1 | Greg Burri | |
| 356 | 2 | Greg Burri | *s -> c* |
| 357 | <pre> |
||
| 358 | 1 | Greg Burri | <ok> |
| 359 | 2 | Greg Burri | </pre> |
| 360 | 1 | Greg Burri | ou |
| 361 | 2 | Greg Burri | <pre> |
| 362 | 1 | Greg Burri | <error> |
| 363 | 2 | Greg Burri | </pre> |
| 364 | 1 | Greg Burri | |
| 365 | |||
| 366 | 2 | Greg Burri | h3. Envoie message |
| 367 | |||
| 368 | 1 | Greg Burri | Le client envoie un message, le message peut répondre à un certain nombre d'autres messages. |
| 369 | "answer_to" n'est pas obligatoire. |
||
| 370 | |||
| 371 | 2 | Greg Burri | *c -> s* |
| 372 | <pre> |
||
| 373 | 1 | Greg Burri | { |
| 374 | "header" : {action : "put_message", version : 3}, |
||
| 375 | "cookie" : "LKJDLAKSJBFLKASN", |
||
| 376 | "nick" : "Paul", |
||
| 377 | "content" : "Bonjour", |
||
| 378 | "answer_to" : [ 345, 532, ... ] |
||
| 379 | } |
||
| 380 | 2 | Greg Burri | </pre> |
| 381 | 1 | Greg Burri | |
| 382 | 2 | Greg Burri | *s -> c* |
| 383 | <pre> |
||
| 384 | 1 | Greg Burri | <ok> |
| 385 | 2 | Greg Burri | </pre> |
| 386 | 1 | Greg Burri | ou |
| 387 | 2 | Greg Burri | <pre> |
| 388 | 1 | Greg Burri | <error> |
| 389 | 2 | Greg Burri | </pre> |
| 390 | 1 | Greg Burri | |
| 391 | |||
| 392 | 2 | Greg Burri | h3. Slapage |
| 393 | |||
| 394 | *c -> s* |
||
| 395 | <pre> |
||
| 396 | 1 | Greg Burri | { |
| 397 | "header" : {action : "slap", version : 3}, |
||
| 398 | "cookie" : "LKJDLAKSJBFLKASN", |
||
| 399 | "user_id" : 67, |
||
| 400 | "reason" : "blablabla" |
||
| 401 | } |
||
| 402 | 2 | Greg Burri | </pre> |
| 403 | 1 | Greg Burri | |
| 404 | 2 | Greg Burri | |
| 405 | *s -> c* |
||
| 406 | <pre> |
||
| 407 | 1 | Greg Burri | <ok> |
| 408 | 2 | Greg Burri | </pre> |
| 409 | 1 | Greg Burri | ou |
| 410 | 2 | Greg Burri | <pre> |
| 411 | 1 | Greg Burri | <error> |
| 412 | 2 | Greg Burri | </pre> |
| 413 | 1 | Greg Burri | |
| 414 | |||
| 415 | 2 | Greg Burri | h3. Bannissement |
| 416 | |||
| 417 | *c -> s* |
||
| 418 | <pre> |
||
| 419 | 1 | Greg Burri | { |
| 420 | "header" : {action : "ban", version : 3}, |
||
| 421 | "cookie" : "LKJDLAKSJBFLKASN", |
||
| 422 | "duration" : 15, // en minute |
||
| 423 | "user_id" : 67, |
||
| 424 | "reason" : "blablabla" |
||
| 425 | } |
||
| 426 | 2 | Greg Burri | </pre> |
| 427 | 1 | Greg Burri | |
| 428 | 2 | Greg Burri | |
| 429 | *s -> c* |
||
| 430 | <pre> |
||
| 431 | 1 | Greg Burri | <ok> |
| 432 | 2 | Greg Burri | </pre> |
| 433 | 1 | Greg Burri | ou |
| 434 | 2 | Greg Burri | <pre> |
| 435 | 1 | Greg Burri | <error> |
| 436 | 2 | Greg Burri | </pre> |
| 437 | 1 | Greg Burri | |
| 438 | |||
| 439 | 2 | Greg Burri | h3. Liste des ip bannis |
| 440 | |||
| 441 | *c -> s* |
||
| 442 | <pre> |
||
| 443 | 1 | Greg Burri | { |
| 444 | "header" : {action : "list_banned_ips", version : 3}, |
||
| 445 | "cookie" : "LKJDLAKSJBFLKASN" |
||
| 446 | } |
||
| 447 | 2 | Greg Burri | </pre> |
| 448 | 1 | Greg Burri | |
| 449 | 2 | Greg Burri | *s -> c* |
| 450 | <pre> |
||
| 451 | 1 | Greg Burri | { |
| 452 | "reply" : "list_banned_ips", |
||
| 453 | "list" : [ |
||
| 454 | { |
||
| 455 | ip : "192.168.1.2", |
||
| 456 | remaining_time : "1h23" |
||
| 457 | users : [ |
||
| 458 | { |
||
| 459 | nick : "Pierre" , |
||
| 460 | login : "pierre" |
||
| 461 | } |
||
| 462 | ] |
||
| 463 | } |
||
| 464 | ] |
||
| 465 | } |
||
| 466 | 2 | Greg Burri | </pre> |
| 467 | 1 | Greg Burri | |
| 468 | 2 | Greg Burri | h3. Débannissement |
| 469 | |||
| 470 | *c -> s* |
||
| 471 | <pre> |
||
| 472 | 1 | Greg Burri | { |
| 473 | "header" : {action : "unban", version : 3}, |
||
| 474 | "cookie" : "LKJDLAKSJBFLKASN" |
||
| 475 | "ip" : "192.168.1.2" |
||
| 476 | } |
||
| 477 | 2 | Greg Burri | </pre> |
| 478 | |||
| 479 | *s -> c* |
||
| 480 | <pre> |
||
| 481 | 1 | Greg Burri | <ok> |
| 482 | 2 | Greg Burri | </pre> |
| 483 | 1 | Greg Burri | ou |
| 484 | 2 | Greg Burri | <pre> |
| 485 | 1 | Greg Burri | <error> |
| 486 | 2 | Greg Burri | </pre> |
| 487 | 1 | Greg Burri | |
| 488 | |||
| 489 | 2 | Greg Burri | h3. Ajout d'une correction d'un messages |
| 490 | |||
| 491 | _(non implémenté, améliorer pour la modification complète d'un message)_ |
||
| 492 | 1 | Greg Burri | Le client envoie un correctif sous la forme de texte supplémentaire à appondre au dernier messages. |
| 493 | Le message est appondu avec un " +++ " devant, par exemple : |
||
| 494 | > Gnome c'est mieux que KDE +++ Euh non ok, c'est faux |
||
| 495 | |||
| 496 | 3 | Greg Burri | *c -> s* |
| 497 | <pre> |
||
| 498 | 1 | Greg Burri | { |
| 499 | "header" : {action : "correction", version : 3}, |
||
| 500 | "cookie" : "LKJDLAKSJBFLKASN", |
||
| 501 | "content" : "Euh non ok, c'est faux" |
||
| 502 | } |
||
| 503 | 3 | Greg Burri | </pre> |
| 504 | |||
| 505 | *s -> c* |
||
| 506 | <pre> |
||
| 507 | 1 | Greg Burri | { |
| 508 | "reply" : "correction", |
||
| 509 | "status" : "ok" | "error", |
||
| 510 | "message_error" : "blabla" |
||
| 511 | } |
||
| 512 | 3 | Greg Burri | </pre> |