handleMessage method

bool handleMessage(
  1. dynamic telegram
)

Tries to dispatch the massage to the current or global state and returns true if the message was processed successfully.

Implementation

bool handleMessage( telegram ) {
	// first see, if the current state is valid and that it can handle the message

	if (currentState != null && currentState?.onMessage( owner, telegram ) == true ) {
		return true;
	}

	// if not, and if a global state has been implemented, send the message to the global state

	if (globalState != null && globalState?.onMessage( owner, telegram ) == true ) {
		return true;
	}

	return false;
}