Client Reference

Client Session

Client session is the recommended interface for subscribing and publish to a hpfeeds broker with asyncio.

class hpfeeds.asyncio.ClientSession(host, port, ident, secret)

The class for creating client sessions and publish/subscribing.

Instances of this class will automatically maintain a connection to the broker and try to reconnect if that connection fails.

param str host:The broker to connect to
param str port:The port to connect to
param str ident:
 The identity to authenticate with
param str secret:
 The secret to authenticate with
coroutine read()

Returns a message received by the broker. It’s future will not fire until a message is available.

publish(channel, payload)
Parameters:
  • channel (str) – The channel to post the payload to.
  • payload (bytes) – The data to publish to the broker.

Send the given payload to the given channel.

subscribe(channel)
Parameters:channel (str) – The channel to subscribe to.

Subscribe to the named channel.

unsubscribe(channel)
Parameters:channel (str) – The channel to subscribe to.

Unsubscribe from the named channel.