Skip to content

Commit

Permalink
Update client-libraries-websocket.md (apache#11641)
Browse files Browse the repository at this point in the history
  • Loading branch information
tspannhw authored Aug 15, 2021
1 parent 50e6b3e commit c600197
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion site2/docs/client-libraries-websocket.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,15 @@ TOPIC = scheme + '://localhost:8080/ws/v2/producer/persistent/public/default/my-

ws = websocket.create_connection(TOPIC)

# encode message
s = "Hello World"
firstEncoded = s.encode("UTF-8")
binaryEncoded = base64.b64encode(firstEncoded)
payloadString = binaryEncoded.decode('UTF-8')

# Send one message as JSON
ws.send(json.dumps({
'payload' : base64.b64encode('Hello World'),
'payload' : payloadString,
'properties': {
'key1' : 'value1',
'key2' : 'value2'
Expand Down

0 comments on commit c600197

Please sign in to comment.