Team XSockets.NET

Storage

This feature lets you store any serializable object on the server by using simple methods on the client API's. This is useful when you need to store data between connections/pages for the client. You are responsible for cleaning up the memory your self since data written to the storage will remain there until you remove it or the server stops. You can also write your own module for storage as shown in storage section and the part abour Azure Storage Table

When you use the storage you always work on a controller instance since each controller can have its own storage

Note: You can set any serializable object as value in the storage

Setting data on the server

Set the generic type that you want to store (in this case string)

conn.Controller("chat").StorageSet("color","blue");

Get notifications when the data changes on the server

Since the storage is per client you will only get notifications for changes in the current client.

conn.Controller("chat").StorageOnSet<string>("color", s => Console.WriteLine("Color {0} was set in storage", s));

Getting data from the server

var color = conn.Controller("chat").StorageGet<string>("color");
Console.WriteLine("Got color {0} from storage", color);

Removing data on the server

conn.Controller("chat").StorageRemove("color");

Get notifications when the data is removed on the server

conn.Controller("chat").StorageOnRemove<string>("color", s => Console.WriteLine("Color {0} was removed from storage", s));

Clear the storage

conn.Controller("chat").StorageClear();

results matching ""

    No results matching ""