brettpoole / growl

Automatically exported from code.google.com/p/growl
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

WebSocket support #549

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What feature or enhancement do you propose?
WebSocket support in our GNTP implementation

What problem does it solve/What benefit does it provide?
It would allow GNTP notifications to come straight from web pages without the 
need for flash.

We presently have stubbed in support for the initial 4 bytes of the socket as 
being a web socket, and implementing the hand shake is easily doable (did so in 
my initial tests fairly quickly).  However, WebSocket data coming in and going 
out must be framed before being sent.  Presently GNTPServer is not really 
suited to inserting this into the middle of the server code, doing so would 
require pretty significant rewrites to it.  

In general, this sort of thing should be handled by the transport mechanism, 
not the server logic anyways.  My thinking at the moment is a wrapper for 
GCDAsyncSocket.  We will pass ownership of an incoming websocket's 
GCDAsyncSocket to an instance of the wrapper (which will then finish up the 
hand shake), then we store that wrapper away as our socket for that host.  All 
our read, and write calls will remain the same in GNTPServer, we will get 
callbacks the same as we presently do.  Internally it will need to handle 
reading in frames, parsing them, de mixing them, and buffering them for our 
read calls.  It will have to handle timing out reads due to adding another 
layer of potential asynchronous behavior into our async networking (timing out 
writes can be handled by GCDAsyncSocket still).  

What needs to make this happen? time mainly, its going to take some thinking, 
and testing, and probably lots of debugging.  

Original issue reported on code.google.com by dan...@growl.info on 2 Nov 2012 at 2:40

GoogleCodeExporter commented 8 years ago
I was a bit bored on sunday night, and decided to play with this.  It is now 
working, and stored in a feature branch  for the present. 
I am flagging this as fixed in source,  Whether or not this will make it into 
2.1 or a later release is something we will discuss, it will need more testing, 
and both websocket and flash support need some kind of off switch available, 
either individually or together.

The method described above of using a proxy wrapper around the GCDAsyncSocket 
for a WebSocket originated note was the method chosen, all calls to read go 
through it, and read out of a buffer of deframed data.  Outgoing data is framed 
appropriately, and sent out.

Original comment by dan...@growl.info on 5 Nov 2012 at 8:54