These are chat archives for fanout/pushpin

Nov 2016
Justin Karneges
Nov 27 2016 02:19
@dfee you can close connections via publish. probably not well documented yet but "ws-message": {"action": "close"} should do it
rather than reconnect/rediscover, you might have an event that indicates what the user recently did (e.g. joined a new chatroom). then clients could react by making an action that would cause them to get subscribed to that info, if they want to be
in general I think it's simpler (architecture-wise) if each client opts in to what they want to listen to, rather than subscriptions being changed behind the scenes by the server
Justin Karneges
Nov 27 2016 02:28
I am considering how to make the server able to change subscriptions. probably we will support another kind of call (or publish "action") that can cause a websocket-over-http session to initiate a new request to the origin. that'd let you send control messages again without the client having be aware of what's happening
this is sort of possible with http streaming by abusing reliability mode. if you deliberately publish an out-of-sequence message, it'll cause the streaming session to make a new request to the server, and you can return different Grip-Channel headers to change the subscriptions, again without the client having to be aware of what's happening
Nov 27 2016 16:27
Hello. I am playing around with pushpin and have a very basic question. I am looking through the documentation and I can get the stream example given in documentation working using the curl method. However, it is not clear how to receive the pushed data in the browser. I tried Ajax, but that does not work. Do I have to use SSE or Websockets to receive data when client visits using a browser (instead of curl)? From the documentation it appears to me that http streaming is different from SSE or Websockets; but I could not find out about it on Google and how to receive the data from the http Stream in a browser. I should note that I did not try publishing to the channel using the post request on 5561. Instead, I used the command line tool pushpin-publish.
Justin Karneges
Nov 27 2016 21:37
Hi @curioustolearn . For streaming to browsers it's best to use SSE format which can be consumed by the EventSource JS API. Or use WebSockets. It is possible to receive arbitrary streamed data using XMLHttpRequest, but this is awkward
pushpin-publish yourchannel "event: message"$'\n'"data: hello world"$'\n'
Justin Karneges
Nov 27 2016 21:43
to send SSE, make sure the Content-Type of the response is text/event-stream and the initial body is empty (or contains initial data in SSE format), then publish like this:
hmm it's possible gitter stored those last two messages out of order
in case it's not clear, SSE is a type of http streaming. essentially, http streaming is where the server uses a response with no content-length, and appends to the response whenever it wants to send data to the client
Justin Karneges
Nov 27 2016 21:48
SSE is a form of this, where there is a designated content type, and each event from the server is a set of lines (divided by a double-newline)
there are other kinds of streaming services though. for example, Twitter's streaming API uses one line per event, and each line is a compact JSON blob
you could also send out binary audio codec chunks to do music streaming
all of these count as http streaming since they all use an endless http response
SSE is great because browsers understand it natively