class Caridina::Syncer

Overview

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.

Defined in:

caridina/syncer.cr

Instance Method Summary

Instance Method Detail

def on(event_type : Events::Event.class, source = Source::All, &listener : EventListener) : Nil #

[View source]
def on(event_type : Events::Event.class, source = Source::All, listener : EventListener | Nil = nil) : Nil #

[View source]
def process_response(sync : Responses::Sync) : Nil #

[View source]