PubSub - Python
PubSub
one of the property of a Meeting Class is used for messaging purpose for an ongoing meeting
Methods​
publish()​
-
publish()
is used to publish messages on a specified topic in the meeting. -
While publishing message, if you provide
persist
astrue
, then it will persist the message throughout the meeting and newly joined partcipant will get all old messages of a meeting, otherwise not.
Parameters​
Returns​
void
Example​
from videosdk import PubSubPublishConfig
pubsub_config = PubSubPublishConfig(
topic="CHAT",
message=description
)
meeting.pubsub.publish(pubsub_config)
subscribe()​
subscribe()
is used to subscribe a particular topic to get all the messages of that particular topic in the meeting. Whilepublish()
subscribe callback will be invoked.
Parameters​
Returns​
-
This will return old messages for this topic, if you passed
persist
totrue
while publish -
List<message>
Example​
from videosdk import PubSubSubscribeConfig
def on_pubsub_message(pubsub_message):
pass
pubsub_config = PubSubSubscribeConfig(
topic="CHAT",
cb=on_pubsub_message
)
old_messages = await self.meeting.pubsub.subscribe(pubsub_config)
unsubscribe()​
unsubscribe()
is used to unsubscribe a particular topic on which you have subscribed priviously.
Parameters​
- topic :
- type :
str
- type :
Returns​
void
Example​
meeting.pubsub.unsubscribe("CHAT")
Pubsub message data​
message​
-
type :
str
-
Message that has been published on the specific topic.
senderId​
-
type :
str
-
id of a sender who has published this message.
senderName​
-
type :
str
-
Name of a sender who has published this message.
timestamp​
-
type :
Date
-
Timestamp of when a message has been published.
topic​
-
type :
str
-
Name of the topic.
payload​
-
type :
dict
-
The additional data that you have send with message.
Got a Question? Ask us on discord