class

Caridina::Syncer

Inherits Reference < Object

This object allow you to register listeners to be executed when some events are received.

This avoid you to have to parse the whole Responses::Sync. However #process_response must be called with a Responses::Sync manually. This allow you to control precisely when you want to handle events.

syncer = Caridina::Syncer.new
syncer.on(Caridina::Events::Message) do |event|
  # TODO: actually do something
end

syncer.process_response(sync)

Events sent to listeners are Events::Event objects. You should use a type restriction in order to access all their fields.

Instance methods

on(event_type : Events::Event.class, source = Source::All, &listener : EventListener) : Nil
Source
on(event_type : Events::Event.class, source = Source::All, listener : EventListener | Nil = nil) : Nil
Source
process_response(sync : Responses::Sync) : Nil
Source

Nested types