0
をプリントアウトしていない:これは私の加入者がPythonのPubNubの加入者は、これが私の出版社であるメッセージ
from pubnub.pnconfiguration import PNConfiguration
from pubnub.pubnub import PubNub
def publish_callback(result, status):
print(result)
print(status)
# Handle PNPublishResult and PNStatus
pnconfig = PNConfiguration()
pnconfig.subscribe_key = 'sub-c-ec413276-b805-11e6-b737-xxxxx'
pnconfig.publish_key = 'pub-c-528502df-76a6-4f07-8636-xxxxx'
pubnub = PubNub(pnconfig)
pubnub.publish().channel("awesomeChannel").message("hello!!").async(publish_callback)
ある
from pubnub.pnconfiguration import PNConfiguration
from pubnub.pubnub import PubNub
from pubnubtets import MySubscribeCallback
pnconfig = PNConfiguration()
pnconfig.subscribe_key = 'sub-c-ec413276-b805-11e6-b737-xxxxx'
pnconfig.publish_key = 'pub-c-528502df-76a6-4f07-8636-xxxxx'
pubnub = PubNub(pnconfig)
pubnub.add_listener(MySubscribeCallback())
pubnub.subscribe().channels('awesomeChannel').execute()
これは私のコールバックです:
from pubnub.callbacks import SubscribeCallback
from pubnub.enums import PNStatusCategory
class MySubscribeCallback(SubscribeCallback):
def presence(self, pubnub, presence):
print(presence)
def status(self, pubnub, status):
if status.category == PNStatusCategory.PNUnexpectedDisconnectCategory:
pass # This event happens when radio/connectivity is lost
elif status.category == PNStatusCategory.PNConnectedCategory:
# Connect event. You can do stuff like publish, and know you'll get it.
# Or just use the connected event to confirm you are subscribed for
# UI/internal notifications, etc
pass
elif status.category == PNStatusCategory.PNReconnectedCategory:
pass
# Happens as part of our regular operation. This event happens when
# radio/connectivity is lost, then regained.
elif status.category == PNStatusCategory.PNDecryptionErrorCategory:
pass
# Handle message decryption error. Probably client configured to
# encrypt messages and on live data feed it received plain text.
def message(self, pubnub, message):
print(message)
問題私はそれを聞いているサブスクライバを実行し、メッセージを送信するためにパブリッシャを実行するときですhello!!
私のコールバックgeそれは私がメッセージを印刷するときにそれは<pubnub.models.consumer.pubsub.PNMessageResult object at 0x108453278>
を印刷します。実際に私のメッセージを私に見せてほしい。hello!!
。
紛失しているものがありますか? pubnub python sdk docsから