ably / ably-php

PHP client library SDK for Ably realtime messaging service
https://ably.com/download
Apache License 2.0
51 stars 10 forks source link

Ability to subscribe from the server #47

Closed softmonkeyjapan closed 6 years ago

softmonkeyjapan commented 6 years ago

Hi,

We are using Ably to maintain the state of our APIs, mainly built using Ruby on Rails. Your Ruby SDK (https://github.com/ably/ably-ruby#subscribing-to-a-channel) allows us to subscribe from the server like this using Ably::Realtime.new:

Thread.new do
  EventMachine.run do
    channel = ABLY_REALTIME.channels.get('identity')
    channel.subscribe('updateUser') do |msg|
      # code
    end
  end
end

However, we can't seems to be able to find the same feature for the PHP SDK. Is there any particular reason why it is not implemented ? Is there a workaround ? One of our API is built in PHP and we are struggling syncing it with the rest of our stack.

Thanks for reading this.

paddybyers commented 6 years ago

The PHP implements the REST library only (see https://www.ably.io/download) and so do not support realtime (websocket) connections and channel subscriptions.

We don't have any plans at present to extend PHP to a realtime library.

Might an alternative be to use an MQTT client library (eg https://github.com/oliverlorenz/phpMqttClient ?). Ably supports MQTT subscriptions (https://support.ably.io/support/solutions/articles/3000060409-why-would-i-use-mqtt-over-ably-s-realtime-protocol-)

softmonkeyjapan commented 6 years ago

@paddybyers thanks a lot for those explanations. For now, we've created a NodeJs microservice that is responsible of feeding our PHP API with the realtime data. I will take a look at the MQTT alternative which sounds better. Thanks again