Protocols

Phoenix Channel / Presence / LiveView Protocols #

join #

["3", "3", "room:lobby", "phx_join", {"name": "alice"}]
["3","3","room:lobby","phx_reply",{"status":"ok","response":{}}]

leave #

heartbeat #

client => server, request: [null,"4","phoenix","heartbeat",{}] server => client, response: [null,"4","phoenix","phx_reply",{"status":"ok","response":{}}]

presence #

join_ref, ref, topic, event, payload

初始状态 #

[
  "3",
  null,
  "room:lobby",
  "presence_state",
  {
    "alice":{
      "metas":[
        {"phx_ref":"GBeMTTnKQPap8gIC","online_at":"1736010444"},
        {"phx_ref":"GBeMWS5JT12p8gJC","online_at":"1736010496"}
      ]},
    "bob":{
      "metas":[
        {"phx_ref":"GBeMS9geQDWp8gHi","online_at":"1736010438"}
      ]
    }
  }
]

变化 #

[
  null,
  null,
  "room:lobby",
  "presence_diff",
  {
    "joins": {
      "alice":{
        "metas": [
          {"phx_ref":"GBeMWS5JT12p8gJC","online_at":"1736010496"}
        ]
      }
    },
    "leaves":{}
  }
]