class Citrus::Components::Remote

Remote

Public Class Methods

new(app, args={}) click to toggle source

Initialize the component

@param [Object] app @param [Hash] args

# File lib/citrus/components/remote.rb, line 25
def initialize app, args={}
  args[:buffer_msg] = args[:buffer_msg] || false
  args[:interval]  = args[:interval] || 0.03
  @app = app
  @args = args
end

Public Instance Methods

start() { || ... } click to toggle source

Start the component

# File lib/citrus/components/remote.rb, line 33
def start &block
  @args[:port] = @app.cur_server[:port]
  @args[:paths] = get_remote_paths
  @args[:context] = @app

  @remote = CitrusRpc::RpcServer::Server.new @args
  @remote.start

  EM.next_tick { block_given? and yield }
end
stop(force=false) { || ... } click to toggle source

Stop the component

@param [Boolean] force

# File lib/citrus/components/remote.rb, line 47
def stop force=false, &block
  @remote.stop force
  EM.next_tick { block_given? and yield }
end

Private Instance Methods

get_remote_paths() click to toggle source

Get remote paths

# File lib/citrus/components/remote.rb, line 55
def get_remote_paths
  paths = []

  role = @app.frontend? sinfo ? :frontend : :backend
  server_type = sinfo[:server_type]

  sys_path = get_sys_remote_path role
  paths << remote_path_record('sys', server_type, sys_path) if sys_path

  user_path = get_user_remote_path @app.base, server_type
  paths << remote_path_record('user', server_type, user_path) if user_path

  paths
end