Protocol Dataset | Replicate Table

This mode tries to solve a common scenario where a table is replicated for all connected clients, example, if you have a server with a stock quotes table, you want broadcast stock changes to all clients, but you don't want that a client can connect to your database. So, every time there is a change in any stock quotes, the record information will be broadcasted to all connected clients. Every client will read the record and update his own table.

 

You can check in Demos folder, SQLLite/MultipleDatabase demo.

Configure Dataset Server

Create a new Dataset Protocol Server and configure using the following properties

 

 


oServer := TsgcWebSocketServer.Create(nil);
oProtocolDataset := TsgcWSPServer_Dataset.Create(nil);
oProtocolDataset.Server := oServer;
oProtocolDataset.Dataset := <...your dataset..>;
oProtocolDataset.ApplyUpdates := true;
oProtocolDataset.AutoSynchronize := true;
oProtocolDataset.NotifyUpdates := true;
oProtocolDataset.UpdateMode := upWhereAll;
oServer.Port := 80;
oServer.Active := true;

 

Configure Dataset Client

Create a new Dataset Protocol Client and configure using the following properties

 

 


oClient := TsgcWebSocketClient.Create(nil);
oProtocolDataset := TsgcWSPClient_Dataset.Create(nil);
oProtocolDataset.Client := oClient;
oProtocolDataset.Dataset := <...your dataset..>;
oProtocolDataset.ApplyUpdates := true;
oProtocolDataset.AutoSubscribe := true;
oProtocolDataset.NotifyUpdates := true;
oProtocolDataset.UpdateMode := upWhereAll;
oClient.Host := '127.0.0.1';
oClient.Port := 80;
oClient.Active := true;