spec/invoker/power/web_sockets_spec.rb
# Full integration test. Start a server, and client. Let client interact with
# server do a ping-pong. Client checks whether ping pong is successful or not.
# Also, mock rewriter so that it returns valid port for request proxying.
# - Server will run on port 28080.
# - Balancer will run on port 28081 proxying to 28080
# - Client will connect to 28081 performing ping-pong
Full integration test. Start a server, and client. Let client interact with
server do a ping-pong. Client checks whether ping pong is successful or not.
Also, mock rewriter so that it returns valid port for request proxying.
Server will run on port 28080.
Balancer will run on port 28081 proxying to 28080
Client will connect to 28081 performing ping-pong
Full integration test . Start a server and client . Let client interact with server do a ping - pong . Client checks whether ping pong is successful or not . Also mock rewriter so that it returns valid port for request proxying . Server will run on port 28080 . Balancer will run on port 28081 proxying to 28080 Client will connect to 28081 performing ping - pong
def websocket_server
  require 'websocket-eventmachine-server'
  EM.run do
    WebSocket::EventMachine::Server.start(host: "0.0.0.0", port: 28080) do |ws|
      ws.onerror { |e| p e }
      ws.onmessage { ws.send "pong" }
    end
    EM.add_timer(2) { EM.stop }
  end
end
def websocket_server require 'websocket-eventmachine-server' EM . run do WebSocket :: EventMachine :: Server . start ( host : "0.0.0.0" , port : 28080 ) do | ws | ws . onerror { | e | p e } ws . onmessage { ws . send "pong" } end EM . add_timer ( 2 ) { EM . stop } end end
Full integration test.
Full integration test .