def subscribe(channel, last_message_id: nil, &callback)
      raise InvalidChannel unless channel.to_s.start_with?("/")
      raise MissingBlock unless block_given?

      last_message_id = -1 if last_message_id && !last_message_id.is_a?(Integer)

      @channels[channel] ||= Channel.new
      channel = @channels[channel]
      channel.last_message_id = last_message_id if last_message_id
      channel.callbacks.push(callback)
      start if stopped?
    end
def subscribe(channel, last_message_id: nil, &callback)
      raise InvalidChannel unless channel.to_s.start_with?("/")
      raise MissingBlock unless block_given?

      last_message_id = -1 if last_message_id && !last_message_id.is_a?(Integer)

      @channels[channel] ||= Channel.new
      channel = @channels[channel]
      channel.last_message_id = last_message_id if last_message_id
      channel.callbacks.push(callback)
      start if stopped?
    end
Subscribes to a channel which executes the given callback when a message
 is published to the channel

 @example Subscribing to a channel for message
   client = MessageBus::HTTPClient.new('http://some.test.com')

   client.subscribe("/test") do |payload, _message_id, _global_id|
     puts payload
   end

 A last_message_id may be provided.
  * -1 will subscribe to all new messages
  * -2 will recieve last message + all new messages
  * -3 will recieve last 2 message + all new messages

 @example Subscribing to a channel with `last_message_id`
   client.subscribe("/test", last_message_id: -2) do |payload|
     puts payload
   end

 @param channel [String] channel to listen for messages on
 @param last_message_id [Integer] last message id to start polling on.

 @yield [data, message_id, global_id]
  callback to be executed whenever a message is received

 @yieldparam data [Hash] data payload of the message received on the channel
 @yieldparam message_id [Integer] id of the message in the channel
 @yieldparam global_id [Integer] id of the message in the global backlog
 @yieldreturn [void]

 @return [Integer] the current status of the client