Is using a JSON object reentrant ...

0 favourites
  • 3 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hello,

    I am writing some code that receives a websocket message from an outside source that is then parsed by a JSON object.

    Once parsed additional processing is handed off to other functions, which are called and refer to the same JSON object.

    I started to wonder if this is all reentrant -- i.e. when during the processing of one websocket message another one arrives, whether the second set of calls are done via an new JSCON instance, or whether the same is reused / overwritten.

    Tagged:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • By default there is a single instance of JSON object. So if you parse a new message in it, the old one will be overwritten.

    You can create new instances of JSON (just like you create new sprite instances). But be careful to always pick the correct instance of JSON in other events and functions. You can distinguish them by instance variable for example.

  • thank you.

    I eventually noticed the create object, and now consistently create a new JSON in each new function body -- with the message to be parsed passed as argument.

    Its more overhead, but i hope like this i don't get into reentrant problems

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)