-
Notifications
You must be signed in to change notification settings - Fork 503
Home
The public(or front) port is the port that clients can connect to and receive messages from the comet server. The default port number is 8100
.
Request:
Long-polling
http://127.0.0.1:8100/poll?cname=$channel&seq=$next_seq&token=$token
Forever iframe
http://127.0.0.1:8100/iframe?cname=$channel&seq=$next_seq&token=$token
Streaming(HTTP endless chunk)
http://127.0.0.1:8100/stream?cname=$channel&seq=$next_seq&token=$token
Parameters:
- cname: The name of the channel this client will subscribe to.
- token: Token is returned by
/sign
. - seq: The sequence number of the next data message that will be sent by iComet server. iComet client must remember every message's sequence number, plus it with 1, and used for next polling or reconnect streaming.
Response:
If the HTTP response tatus code is not 200
, it is likely that the iComet server is down.
Long-polling
icomet_cb([{type: "data", cname: "a", seq: "1", content: "a"}]);
icomet_cb({type: "data", cname: "a", seq: "1", content: "a"});
When there are buffered messages attached with the channel, the response is as the first one, the parameter of the function call is an array of message objects.
When a new message arrives, the response is as the second one, the parameter of the function call is the message object.
Since the response is received, the request is finished, so the client must send another request.
Forever iframe
<script>parent.icomet_cb({type: "data", cname: "a", seq: "0", content: "a"});</script>
Each message(old and new) is responsed as a HTTP chunk, the chunk is a snipet of JavaScript code, the request is not finished, so client do not need to send another request.
Streaming(HTTP endless chunk)
{type: "data", cname: "a", seq: "1", content: "a"}
Each message(old and new) is responsed as a HTTP chunk, the request is not finished, so client do not need to send another request.
Parameters:
- type: The type of this message
- data: A normal message.
- next_seq: The client should reset its seq to the specified seq.
- noop: An heartbeat message.
- 429: Error message, too many channels/subscribers.
- 401: Error message, token error.
The administration(or admin) port is the port that internal services will connect to, to create a channel, publish a message, close a channel, etc. Clients are forbidden to connect to this port. The default port number is 8000
.
Request:
http://127.0.0.1:8000/sign?cname=$channel[&expires=60]
The created channel will be waiting for 60 seconds to expire before any subscriber arrives.
Response:
{type: "sign", cname: "a", seq: 0, token: "36289dcb55bc35aa6893f7557b7fc28c", expires: 30, sub_timeout: 10}
Request:
http://127.0.0.1:8000/push?cname=$channel&content=$content
Response:
{type: "ok"}
/push
is an replacement of /pub
, by using /push
, the icomet server will escape any special char._ Just pass any string to the server by /push
, icomet server will do the rest.
Request:
http://127.0.0.1:8000/pub?cname=$channel&content=$content
Response:
{type: "ok"}
content
must be json encoded string without leading quote and trailing quote.
Request:
http://127.0.0.1:8000/close?cname=$channel
Response:
Get information about the comet-server.
Request:
http://127.0.0.1:8000/info
Response:
{"version": "0.2.2.1", "channels": 0, "subscribers": 0}
Check if a channel is available(created and/or subscriber connected).
Request:
http://127.0.0.1:8000/check?cname=$channel
Response:
{"a": 1}
{}
Subscriber to comet-server's channel creation and deletion events, events are received as HTTP chunks.
Request:
http://127.0.0.1:8000/psub
Response:
1 channel
0 channel