SSL support for eventmachine projects with JRuby

I’ve been hacking on Foxbat for a while now but haven’t really said anything about it. If you’re using JRuby and you want eventmachine to support SSL/TLS, connection timeouts, proper multithreading and more, give it a try. Using it is as simple as requiring the gem before any dependencies. For example, here’s em-websocket‘s initial example with SSL support on Java:

require 'foxbat'
require 'em-websocket'

EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 3333,
    :secure => true, :keystore => '/path/to/keystore') do |ws|
  ws.onopen {
    puts "WebSocket connection open"
     # publish message to the client
    ws.send "Hello Client"
  }

  ws.onclose { puts "Connection closed" }
  ws.onmessage { |msg|
    puts "Recieved message: #{msg}"
    ws.send "Pong: #{msg}"
  }
end

Currently the only subset of EM it supports is TCP clients/servers, SSL, one-shot timers and #defer but it shouldn’t be hard to extend- it’s just a wrapper around netty. Not much else to it.