realtime-py icon indicating copy to clipboard operation
realtime-py copied to clipboard

Payload option for Channel.join() function

Open Maturin opened this issue 9 months ago • 0 comments

Feature request

Is your feature request related to a problem? Please describe.

For an integration project, I need to specify some additional payload, when joining a channel. Therefore, I'd like to enhance the Channel.join function for being able to pass a payload like this:

# common connection and channel setup

join_payload = { 
    "key1": value1,
    "key2": value2
}

channel.join(payload)

Describe the solution you'd like

The Channel._join function foresees already the usage of some payload:

        join_req = dict(topic=self.topic, event="phx_join",
                        payload={}, ref=None)

Therefore, I would add a payload parameter to the join functions, like this:

    def join(self, payload:dict = {}) -> Channel:
        # ...

    async def _join(self, payload:dict) -> None:
        # ...
        join_req = dict(topic=self.topic, event="phx_join",
                        payload=payload, ref=None)
        # ...

Describe alternatives you've considered

n/a

Additional context

This would also effect my ticket #133.

Maturin avatar May 05 '24 12:05 Maturin