Opps, this post is intended to be posted on the Ring group, sorry for 
the noise. 


On Friday, February 15, 2013 5:50:15 PM UTC+8, Feng Shen wrote:
>
> Hi,  I am trying to draft a protocol for realtime communication between 
> client and ring server. 
>
> http-kit <http://http-kit.org/> try to implement the protocol,  provide a 
> fast & scalable ring adapter with websocket & async extension for Clojure 
> web developers.
>
> Here is an initial version, any thought/comment/suggestion welcome. 
>
> (defprotocol Channel
>   "Asynchronous channel for HTTP streaming/long polling & websocekt"
>   (open? [] "Tells whether or not this channel is still open")
>   (close []
>     "Closes this channel.     If this channel is already closed then invoking 
> this method has no effect.     Any further attempt to invoke I/O operations 
> is welcomed by IllegalStateException")
>   (send! [data & [close-after-send]]
>     "Send data to client. Weclomed by IllegalStateException if already closed 
>     If `close-after-send` is true, `close` get called after sent.     For 
> Webocket, a text frame is sent to client.     For streaming:     1. First 
> call of send!, data expect to be {:headers _ :status _ :body _} or just body. 
>        if `close-after-send` is true, a normal HTTP response is assembled and 
> sent to client,        useful for HTTP client that does not support chunked 
> encoding(like ab). Otherwise, a        chunked encoding response is 
> assembled, `close` signals end this response.     2. Any further call, only 
> body(String, File, InputStream, ISeq) is expected.        The data is encoded 
> as chunk, sent to client")
>   (on-send [callback]
>     "Callback: (fn [data])     Do something with the data (like JSON 
> encoding) before sending it off")
>   (on-mesg [callback]
>     "Callback: (fn [message-string])     Set the handler to get notified when 
> there is message from client.     Only valid for websocket. For streaming,    
>  another HTTP connection can be used to emulate the behaviour")
>   (on-close [callback]
>     "Callback: (fn [status])     Set the handler to get notified when channel 
> get closed, by client `close` called.     Callback is called once if server 
> and client both close the channel     Useful for clean up.     Status code: 0 
> if closed by sever, closed by client:     -1 if streaming, websocket: 
> http://tools.ietf.org/html/rfc6455#section-7.4.1";))
>
> Thanks.
> Feng
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to