require 'protocols/websocket'
include ::Orchestrator::Constants
include ::Orchestrator::Transcoder
descriptive_name 'Websocket example'
# clear the keepalive ping
@ws.binary("binstring".bytes)
@ws.binary hex_to_byte("0xdeadbeef")
# NOTE:: you must use wss:// when using port 443 (TLS connection)
@ws = Protocols::Websocket.new(self, "ws://#{remote_address}/path/to/ws/endpoint")
# @ws.add_extension # https://github.com/faye/websocket-extensions-ruby
# @ws.set_header(name, value) # Sets a custom header to be sent as part of the handshake
def received(data, resolve, command)
logger.debug { "Websocket connected" }
def on_message(raw_string)
logger.debug { "received: #{raw_string}" }
# request = JSON.parse(raw_string)
logger.debug { "received ping: #{payload}" }
logger.debug { "received pong: #{payload}" }
logger.debug { "closing... #{event.code} #{event.reason}" }
logger.debug { "ERROR! #{error.message}" }