FRC2706 / giorno

Scouting App made for the 2019-2020 FRC Competition
GNU General Public License v3.0
0 stars 0 forks source link

SyncManager object #12

Open crabctrl opened 5 years ago

crabctrl commented 5 years ago

Basically an extension of #2. We should have a class that handles all the gritty details of syncing, so that the actual syncing interfaces (WiFi, QR codes, whatever) doesn't have to deal with it. Note that the below is not actual valid Java syntax!

I'm going to recommend we output a JSON object, as this is very easy for the sync interfaces to actually interact with. I'll try to figure out more about how these objects will be formatted later, still trying to figure out how we want this to work.

crabctrl commented 5 years ago

One way we could do it is have a Provider interface that we use for any classes that handle some type of data. It could have a methods like toJSON() and update(json) that let the SyncSession object deal with them nicely. This way we can still do fancy things, like store events in a database, instead of having one massive JSON file.

crabctrl commented 5 years ago

The name SyncSession is probably misleading now that I think about it, since it can actually be used across sessions... Instead let's use SyncManager or something.

crabctrl commented 4 years ago

Ok, a base SyncManager class and SyncProvider interface will be pushed to the sync branch momentarily. The way I've decided to do it is have SyncProviders return generic byte[] arrays as "sync objects". The SyncManager will then use this to handle syncing objects.

The handshake will contain the MD5 hashes of each sync object. The handler code will then send any objects which are not present on the system. I've decided to use generic data rather than JSON because it's easier and E F F I C I E N C Y. Note that how individual SyncProviders parse data is up to them, so we could still potentially end up using JSON at some point (although I'd like to avoid it).

crabctrl commented 4 years ago

I have now pushed an absolute monstrosity of a program; it's 140 lines, very dense, and has exactly 4 comments, but it should work. There are some optimizations I could make if it becomes a problem, but I don't think it should be too big of a deal, and none of my ideas would require changing the protocol so it sounds like a later problem.

Still needs to be tested.