Skip to content

Messaging System

Twarit Waikar edited this page Oct 13, 2019 · 5 revisions

Rubeus: Message System

Created by SDSLabs with ❤️

Rubeus Message system adds asynchronous control to the engine. Adding new signals and user-defined functions to handle these signals has been explained below.

Jargon

  • Message System handles two types of commands:
    • Engine commands :
      • These are hardcoded and the user cannot modify them.
      • Deals with the Functions handling different elements of the engine. For example: Command change_window_title changes the title of the game window. All other engine commands can be found in message_codes.cpp file.
    • User Specific commands
      • User can define these according to the game's need.

How to use Message System?

To register(i.e. to create or make) a new command for any function,

RegisterCommand(m_Receiver, m_FuncName, m_Function)                                                               
// m_Receiver -> object
// m_FuncName -> string(name) of the command
// m_Function -> the function to be called on using the registered command.

To run any predefined or registered commands, use the following function

 sendSignal(command, data)
// command -> name of the command to be run
// data -> any data/params need to pass to the function, by default set to nNULL

Contributor's Guide

The commands(or messages) sent through SendSignal function are added to a queue in messageBus through addMessage function. evaluateMessages() function runs on a thread which evaluates and processes the commands stored in the queue until it becomes empty. This thread does not terminate until the queue becomes empty.