Module: LibSL::DSL
- Defined in:
- lib/dsl.rb
Class Method Summary collapse
-
.client ⇒ Object
Client getter.
Instance Method Summary collapse
-
#handle(type, cb = nil, &block) ⇒ Object
Handle the event type given a Proc cb or a block.
-
#send_packet(packet, reliable = false) ⇒ Object
Send packet.
-
#setup(firstname, lastname, password, start = 'last', grid = :agni) ⇒ Object
Setup the client is given.
- #shutdown ⇒ Object
-
#when_ready(cb = nil) {|Symbol| ... } ⇒ Object
Handle the :ready event (syntactic sugar).
- #when_stopped(cb = nil, &block) ⇒ Object
- #when_stopping(cb = nil, &block) ⇒ Object
Class Method Details
Instance Method Details
#handle(type, cb = nil, &block) ⇒ Object
Handle the event type given a Proc cb or a block
39 40 41 42 |
# File 'lib/dsl.rb', line 39 def handle(type, cb=nil, &block) cb ||= Proc.new EventManager::register_handler EventHandler.new(Proc.new, type) end |
#send_packet(packet, reliable = false) ⇒ Object
Send packet
46 47 48 |
# File 'lib/dsl.rb', line 46 def send_packet(packet, reliable=false) client.network_manager.send_packet(packet, reliable) end |
#setup(firstname, lastname, password, start = 'last', grid = :agni) ⇒ Object
Setup the client is given
17 18 19 |
# File 'lib/dsl.rb', line 17 def setup(firstname, lastname, password, start='last', grid=:agni) client.setup firstname, lastname, password, start, grid end |
#shutdown ⇒ Object
50 51 52 |
# File 'lib/dsl.rb', line 50 def shutdown client.stop end |
#when_ready(cb = nil) {|Symbol| ... } ⇒ Object
Handle the :ready event (syntactic sugar)
25 26 27 |
# File 'lib/dsl.rb', line 25 def when_ready(cb=nil, &block) handle(:ready, cb, &block) end |
#when_stopped(cb = nil, &block) ⇒ Object
33 34 35 |
# File 'lib/dsl.rb', line 33 def when_stopped(cb=nil, &block) handle(:stopped, cb, &block) end |
#when_stopping(cb = nil, &block) ⇒ Object
29 30 31 |
# File 'lib/dsl.rb', line 29 def when_stopping(cb=nil, &block) handle(:stopping, cb, &block) end |