class CitrusRpc::RpcServer::Gateway
Public Class Methods
new(args={})
click to toggle source
Create a gateway
@param [Hash] args Options
@option args [Integer] port @option args [Class] acceptor_class @option args [Hash] services
# File lib/citrus-rpc/rpc-server/gateway.rb, line 27 def initialize args={} @port = args[:port] || 3050 @started = false @stoped = false @acceptor_class = args[:acceptor_class] || WsAcceptor @services = args[:services] @acceptor = @acceptor_class.new(args) { |msg, &block| dispatch msg, @services, &block } end
Public Instance Methods
start()
click to toggle source
Start the gateway
# File lib/citrus-rpc/rpc-server/gateway.rb, line 41 def start raise RuntimeError 'gateway already started' if @started @started = true @acceptor.on(:error) { |*args| emit :error, *args } @acceptor.on(:closed) { |*args| emit :closed, *args } @acceptor.listen @port end
stop()
click to toggle source
Stop the gateway
# File lib/citrus-rpc/rpc-server/gateway.rb, line 51 def stop return unless @started && !@stoped @stoped = true @acceptor.close end