comet and clients protocols

October 30, 2018 · View on GitHub

comet supports two protocols to communicate with client: WebSocket, TCP

websocket

Request URL

ws://DOMAIN/sub

HTTP Request Method

WebSocket (JSON Frame). Response is same as the request.

Response Result

{
    "ver": 102,
    "op": 10,
    "seq": 10,
    "body": {"data": "xxx"}
}

Request and Response Parameters

parameteris requiredtypecomment
vertrueintProtocol version
optrueintOperation
seqtrueintSequence number (Server returned number maps to client sent)
bodyjsonThe JSON message pushed

tcp

Request URL

tcp://DOMAIN

Protocol

Binary. Response is same as the request.

Request and Response Parameters

parameteris requiredtypecomment
package lengthtrueint32 bigendianpackage length
header Lengthtrueint16 bigendianheader length
vertrueint16 bigendianProtocol version
operationtrueint32 bigendianOperation
seqtrueint32 bigendianjsonp callback
bodyfalsebinary(packagelenth)(package lenth) - (header length)

Operations

operationcomment
2Client send heartbeat
3Server reply heartbeat
7authentication request
8authentication response