I have a web socket proxy that accepts messages and passes them through to clients (browser and Flash).
In an attempt to optimize I was hoping to GZIP the data that goes over that web socket connection. Is this possible, and/or what are the other approaches that might work for this?
I know that there is a WebSocket extension being worked on according to this StockOverflow question.
My current approach within a Scala/Jetty application:
def compressBytes(bytes:Array[Byte]) = {
val bos = new ByteArrayOutputStream
val gzip = new GZIPOutputStream(bos)
gzip.write(bytes)
gzip.close
bos.toByteArray
}
sent to the client:
def onMessage(bytes:Array[Byte], offset:Int, length:Int) {
serverSocket.connection.sendMessage(compressBytes(bytes), offset, length)
}
Side note: I know that the Sec-WebSocket-Extensions: permessage-deflate is a possibility, but not yet full adopted (Jetty 9 has it I believe)
Thanks