Last post May 05, 2016 02:36 AM by Fei Han - MSFT
May 04, 2016 07:38 PM|riak|LINK
HI, I'm learning C# and to do that I am building a text based RPG using Signalr. I can create a player and save the data as a JSON file. But what I want to do is store that data in a dictionary using the Connection ID as the key. This way any action on the
player data I can get it from the Dictionary and not re-read the JSON file every time.
I created a dictionary to do this and also used the singleton pattern to do it. When I run the code the player info gets stored in the dictionary. I then call another method to retrieve the data but the dictionary is now null.
I'm really confused as to how? It's like every call to the hub creates a new instance. How can I store this data in memory?
May 05, 2016 02:36 AM|Fei Han - MSFT|LINK
what I want to do is store that data in a dictionary using the Connection ID as the key.
I’d like to know when and on which event you store the data with connection id in dictionary. Could you share us a sample code that could reproduce the issue?
Besides, you could check the code that explained how to retain connection and user information in a dictionary in this link.