Method: UState::Server::Connection#receive_message
- Defined in:
- lib/ustate/server/connection.rb
#receive_message(data) ⇒ Object
Called with a message type and data.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ustate/server/connection.rb', line 36 def (data) begin = UState::Message.decode data if states = .states # State update states.each do |state| @index << state end send UState::Message.new(ok: true) elsif q = .query res = @index.query(q) send UState::Message.new(ok: true, states: res) else send UState::Message.new(ok: false, error: "unknown message type") end rescue Exception => e puts e puts e.backtrace.join("\n") m = UState::Message.new(ok: false, error: e.) send m end end |