Skip to content

Protocol

rmx edited this page May 30, 2016 · 1 revision

Basics

  • HTTP and WebSockets are used as the transport layer
    • HTTP for static assets (html, css, models etc.)
    • WebSocket for full-duplex and time critical communication (game state, chat etc.)

WebSockets

WebSockets is still a draft, there are multiple incompatible standards. As of 2011-07-18 only Chrome and Safari support WebSockets (draft hixie-76/hybi-00), in Firefox/Opera it has to be explicitly enabled due to security concerns. Latest draft is hybi-10 (published 2011-07-11).

Packets

Packets sent through the WebSocket are serialized JSON objects. Each packet MUST contain the following members:

  • opcode code of the packet, integer constant of the packet type as described below
  • time_sender local time of the sender, at the time the packet was sent
  • time_receiver local time of the receiver, copied from the last packet received from the receiver
Name Client Server Description Layout
LOGIN Yes No client login (email:string, password:string)
SPAWN No Yes entity with `guid` spawns (guid:int)
DESPAWN No Yes entity with `guid` despawns (guid:int)
MOVE Yes Yes entity with `guid` updates position (x,y) (guid:int, x:float, y:float, z:float)
CAST Yes No entity with `guid` cast spell `spellid` on `target` (guid:int, target:int, spellid:int)
CAST_START No Yes entity with `guid` starts casting spell `spellid` on `target` (guid:int, target:int, spellid:int, duration:float)
CAST_END No Yes entity with `guid` stops casting spell `spellid` on `target` (guid:int, target:int, spellid:int)
DIE No Yes entity with `guid` died (guid:int)
STAT_UPDATE No Yes entity with `guid` has new stats (guid:int, [stat:int, value:float])
DEBUG Yes Yes debug message (msg:string)
Clone this wiki locally