re: SignalR core python client: A simple Chat Hub Client VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Great work! One question, if I want to store the json data coming in through hub_connection.on("ReceiveMessage", print), in a txt file, how would ...
 

Yes, you can, 'print' is only the callback function. If you create a function like this:

import uuid
import json
def save_message(msg):
    with open(f"{uuid.uuid4()}.json",'w+') as fh:
        fh.write(json.dumps(msg))

Then you only need to replace 'print' on the callback register function:

hub_connection.on("ReceiveMessage", save_message)

This changes will save data passed trhoung signalr

 
code of conduct - report abuse