Jump to content

Wait for return value


photo

Recommended Posts

We have a plugin that returns an integer indicating whether the player has been successfully authenticated or not. My problem is that the entire game frame freezes while the result is not yet available. When the database is down, the app does not receive any response and the game hangs. Is there any way to wait for the result while allowing the game to resume independently? One workaround we can use is to call authentication within the function but not wait for the result right there and then and rather let the plugin call a function within the game once the result is available to prevent the game frame from depending on that result. Is there any other way to handle it?

Link to comment

You could also use non-blocking test function e.g. is AuthenticationResultAvailable() which can be tested within Unigine update loop.

Link to comment

The main idea is to implement non-blocking function and a callback function. Then call engine->runWorld() inside that callback function.

 

Here is some pseudocode (this need to be considered as plugin code). Again, this is not UnigineScript:

 

void nonBlockingFunction() {
  thread("do_lot_of_blocking_stuff");
}

void do_lot_of_blocking_stuff() {
  sleep(10000);
  callback();
}

void callback() {
 engine->runWorld("nonBlockingFunctionFinished");
}

Link to comment
×
×
  • Create New...