wheneverUserConnects static method

void wheneverUserConnects(
  1. OnSessionConnected onSessionConnected, {
  2. bool executeIfAlreadyConnected = true,
})

Provide a method that runs whenever a user initially gains connection or regains connection after he or she lost connection

Implementation

static void wheneverUserConnects(OnSessionConnected onSessionConnected,
    {bool executeIfAlreadyConnected = true}) {
  if (executeIfAlreadyConnected && globalSessionInstance.connected)
    onSessionConnected(globalSessionInstance.phoenixSocket!);
  globalSessionInstance.functionsToBeExecutedOnConnect
      .add(onSessionConnected);
}