Sha256: 9747407186ba15665865ccfb035a8b130b70936a9fda6a0614fd73df8d6ad636

Contents?: true

Size: 729 Bytes

Versions: 16

Compression:

Stored size: 729 Bytes

Contents

module Startback
  module Websocket
    module Hub
      class Message

        def initialize(data, socket)
          data = JSON.parse(data, symbolize_names: true)
          @headers = data[:headers] || {}
          @body = data[:body] || {}
          @socket = socket
        end
        attr_reader :headers, :body, :socket

        def reply(message)
          raise "No reply-to header found" unless headers[:'reply-to']
          response = {
            headers: {
              :'in-reply-to' => headers[:'reply-to']
            },
            body: message
          }
          @socket.send(response.to_json)
        end

      end # class Message
    end # module Hub
  end # module Websocket
end # module Startback

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
startback-websocket-0.17.4 lib/startback/websocket/hub/message.rb
startback-websocket-0.17.3 lib/startback/websocket/hub/message.rb
startback-websocket-0.17.2 lib/startback/websocket/hub/message.rb
startback-websocket-0.17.1 lib/startback/websocket/hub/message.rb
startback-websocket-0.17.0 lib/startback/websocket/hub/message.rb
startback-websocket-0.16.0 lib/startback/websocket/hub/message.rb
startback-websocket-0.15.5 lib/startback/websocket/hub/message.rb
startback-websocket-0.15.4 lib/startback/websocket/hub/message.rb
startback-websocket-0.15.3 lib/startback/websocket/hub/message.rb
startback-websocket-0.15.2 lib/startback/websocket/hub/message.rb
startback-websocket-0.15.1 lib/startback/websocket/hub/message.rb
startback-websocket-0.15.0 lib/startback/websocket/hub/message.rb
startback-websocket-0.14.4 lib/startback/websocket/hub/message.rb
startback-websocket-0.14.3 lib/startback/websocket/hub/message.rb
startback-websocket-0.14.2 lib/startback/websocket/hub/message.rb
startback-websocket-0.14.1 lib/startback/websocket/hub/message.rb