Module: LibSL::DSL

Defined in:
lib/dsl.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.clientObject

Client getter



5
6
7
# File 'lib/dsl.rb', line 5

def client
	@client ||= Client.new
end

Instance Method Details

#handle(type, cb = nil, &block) ⇒ Object

Handle the event type given a Proc cb or a block

Parameters:

  • type (Symbol)

    The event type



52
53
54
55
# File 'lib/dsl.rb', line 52

def handle(type, cb=nil, &block)
	cb ||= Proc.new
	EventManager::register_handler EventHandler.new(Proc.new, type)
end

#loggerObject



10
11
12
# File 'lib/dsl.rb', line 10

def logger
	client.logger
end

#send_packet(packet, reliable = false) ⇒ Object

Send packet

Parameters:



59
60
61
# File 'lib/dsl.rb', line 59

def send_packet(packet, reliable=false)
	client.network_manager.send_packet(packet, reliable)
end

#set_logging(output, debug = false, colors = true) ⇒ Object

Configure logging

Parameters:

  • output (String)

    Path to a logfile

  • output (IOS)

    An output stream ($stdout, $stderr, etc..)

  • debug (Bool) (defaults to: false)

    (optional) Enable debug messages

  • colors (Bool) (defaults to: true)

    (optional) Enable ANSI coloring for terminal emulators



19
20
21
# File 'lib/dsl.rb', line 19

def set_logging(output, debug=false, colors=true)
	client.logger = Logger.new(output, debug, colors)
end

#setup(firstname, lastname, password, start = 'last', grid = :agni) ⇒ Object

Setup the client is given

Parameters:

  • firstname (String)

    Avatar firstname or account username

  • lastname (String)

    (optional) Account lastname. Or ‘Resident’ if a username

  • password (String)

    Password

  • start (String) (defaults to: 'last')

    (optional) The starting location to connect to. ‘last’ or ‘home’ or [REGION NAME]&&[Y]

  • grid (Symbol) (defaults to: :agni)

    (optional) The grid to connect to (:agni for Main grid or :aditi for beta grid)



30
31
32
# File 'lib/dsl.rb', line 30

def setup(firstname, lastname, password, start='last', grid=:agni)
	client.setup firstname, lastname, password, start, grid
end

#shutdownObject



63
64
65
# File 'lib/dsl.rb', line 63

def shutdown
	client.stop
end

#when_ready(cb = nil) {|Symbol| ... } ⇒ Object

Handle the :ready event (syntactic sugar)

Parameters:

  • cb (Proc) (defaults to: nil)

    (optional) An optional Proc that is called when the event is fired

Yields:

  • (Symbol)

    Event type

  • (*args)

    Event specific arguments



38
39
40
# File 'lib/dsl.rb', line 38

def when_ready(cb=nil, &block)
	handle(:ready, cb, &block)
end

#when_stopped(cb = nil, &block) ⇒ Object



46
47
48
# File 'lib/dsl.rb', line 46

def when_stopped(cb=nil, &block)
	handle(:stopped, cb, &block)
end

#when_stopping(cb = nil, &block) ⇒ Object



42
43
44
# File 'lib/dsl.rb', line 42

def when_stopping(cb=nil, &block)
	handle(:stopping, cb, &block)
end