Class: Citrus::Common::Service::HandlerService
- Inherits:
-
Object
- Object
- Citrus::Common::Service::HandlerService
- Defined in:
- lib/citrus/common/service/handler_service.rb
Overview
HandlerService
Instance Method Summary collapse
-
#handle(route_record, msg, session, &block) ⇒ Object
Handle message from the client.
-
#initialize(app, handlers = {}) ⇒ HandlerService
constructor
Initialize the service.
Constructor Details
#initialize(app, handlers = {}) ⇒ HandlerService
Initialize the service
22 23 24 25 |
# File 'lib/citrus/common/service/handler_service.rb', line 22 def initialize app, handlers={} @app = app @handlers = handlers end |
Instance Method Details
#handle(route_record, msg, session, &block) ⇒ Object
Handle message from the client
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/citrus/common/service/handler_service.rb', line 32 def handle route_record, msg, session, &block handler = get_handler route_record unless handler block_given? and yield Exception.new 'failed to find the handler' return end handler.send(route_record['method'], msg, session) { |err, resp, args| block_given? and yield err, resp, args } end |