sgcWebSockets Dataset Subprotocol allows to broadcast database changes to all client connected. From sgcWebSockets 4.3.8 this protocol allows 2 update modes:
1. Replicate Table: protocol updates dataset clients when a dataset has changed.
2. Notify Updates: protocol notifies clients when a dataset has changed.
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;
This mode tries to solve an scenario where server and clients share a single database (server and clients are connected to the same physical database) and clients want to be notified every time other client has done any change on a dataset.
You can check in Demos folder, SQLLite/SingleDatabase demo.
Configure Dataset ServerCreate 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 := false; oProtocolDataset.NotifyUpdates := true; oProtocolDataset.UpdateMode := upRefreshAll; >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 := upRefreshAll; oClient.Host := '127.0.0.1'; oClient.Port := 80; oClient.Active := true;
When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.