If you are willing to build on go, we open sourced the "wc" (WebChannel) library which handles all of the messages for dropinchat.
http://gopkg.in/samegoal/wc.v0
Also, out of curiosity, if dropinchat provided a virtual appliance so that you didn't need to send the messages off network would that address your security concerns?