How do I sync?

Good time of day.
The bottom line is this: there are clients (Windows applications) and you need to synchronize data on them.
While there is an idea like this:

  1. SignalR to notify that new data is available;
  2. RestAPI for CRUD;

That is, for each API request, the API will tell SignalR'y to notify clients of the new data.

Say that you can just drive all the data through SignalR, but, for example, when you first connect there will be a request to get all the relevant data, and there may be, for example, 10,000 (let's say data about users), SignalR may not take out such a load (how much does it have there limit, 32kb?), and I do not think that this is the right way.

How much is it real and whether it is correct.
The main question is how to do it correctly.
p. s. - the load is not large, so I assume that SignalR and the API will be on the same server.

Author: LiptonDev, 2020-10-30

1 answers

I would use SignalR to send a message about new data, after which the clients themselves should call the necessary API for synchronization.

Is it really possible to transfer 10MB of data in JSON with the API, for example?

Why give 10mb in json, do the return page by page. Well, 10mb is not much.

How would it be better to use a separate server with SignalR and a separate one for the API? Or can I throw everything in 1?

You can use the servers as you like (depends on your requirements), there is no difference for customers. Unless you need to authenticate twice.

You must save the time of the last synchronization on the client, so that you do not forward the entire database, but only the data that was updated/added with the time of the last synchronization

In theory, there should be no difference for you, the client is synchronized just every half hour or on a signal, the API for synchronization will be the same.

Is it possible to use a single JWT token for SignalR and API, if they are separate?

As for the jwt, it depends on who issued it and how, because you will need to check its validity on the server.

How do I save the data from the client and check it on the server when connecting? How do I understand on the client that, for example, 1 order was deleted from the database?

There are many ways. First, the order is not deleted from the database, it is marked as deleted. You can store all actions in a separate table with date/time and roll these actions to the client, or you can store the date of the last change to the order in the order table and use this date to understand whether this order should be synchronized or not. Here everything depends entirely on your task.

 3
Author: tym32167, 2020-10-30 17:17:09