c# - What's a good way to send changes to an object over a socket? -


i'm trying implement system synchronising changes in objects on tcp. want generic system can use number of different objects. object in case set of key-value pairs, array of objects, or map of strings objects. object structure changes, values change multiple times per second.

i'm trying implement sends changes instead of serializing entire object every time changes can reduce bandwidth requirements , reduce latency.

what i'm thinking of right turning this:

[ { a: 5, b: "abc"}, { a: 3, b: "xyz" } ]

into set of 1-dimensional arrays:

values = [ 5, "abc", 3, "xyz" ] objects = [ { a: 0, b: 1 }, { a: 2, b: 3 } ] conainer = [ [ 0, 1 ] ]

the integers point element in 1 of 3 arrays. elements point sent in advance , shouldn't change. when value changes, thing needs sent index in value array , new value.

i feeling i'm massively over-thinking (read: i'm pretty sure i'm making million times more complicated needs be). easy if hard-code object-structure. started implementing system described above, it's getting complex feel there must easier way this, not involve re-sending entire object when changes.

edit: seems didn't explain myself well. i'll have go:

i need send changes object/model/datastructure/whatever want call (i use object in rest of post) on internet. since values in objects change lot, structure want send changes, not serialize entire object every single time , send entire thing on network if 1 single integer increases one.

this object not have know structure @ compile time, can't hardcode it. @ runtime structure known, , values change lot.

an object may, example, this:

foo {     int a, b, c }  bar {     foo[] foos = { ... }     int a, b, c }  baz {     map<string, bar> bars = { ... } } 

this structure known before sending changes, , not change while program running, isn't known @ compile time. (it can changed user)


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -