serialization - Typed data over a MessageBox? -


i'm thinking writing dart based browser game. separate core game logic client render , event handling code. way can run same logic code on server dart vm side in multiplayer system. lots of games doing today (eg. quake series): have local server if play single player game.

so in scenario:

  • event handling , rendering runs on main browser thread (render loop triggered requestanimationframe)
  • game logic runs in separate isolate (actually webworker in browser)
  • for communication i'm using messageboxes bit cumbersome setup , manage it's possible. can later exchanged websocket if logic runs on server.

the logic isolate sends messages main thread loop game events (like game object's status being updated, map change, etc.) , main thread posts client side events (key press based player movement, commands) logic.

i'm wondering what's best way manage messages on layer. documentation of messagebox: "the content of message can be: primitive values (null, num, bool, double, string), instances of isolatesinks, , lists , maps elements of these." these simple data transmission if pass whole data beans? solution found json serialization can done relatively painlessly jsonobject. have string can passed on messagebox/websocket.

i wonder how design is? json serialization , deserialization occurs each data on connection. i'm affraid of overhead introduces, channel used lot.

is there can improve this?

a couple possibilities:

  1. does sending typed data list work? vm should able transfer typed data lists between isolates. not sure how dart2js handles things.
  2. take binary data , base64 encode string transmission. less compact pure binary data (1.2x space increase) work.

john


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -