Class TMessaging

Unit

Declaration

type TMessaging = class(TObject)

Description

Message system to communicate between native code (Pascal) and other languages (Java on Android, Objective-C on iOS) that possibly run in other thread. Use through auto-created Messaging singleton. On platforms other than Android / iOS, it simply does nothing — messsages are not send anywhere.

To make this work, on Android you need to declare your Android project type as "integrated" (this is actually the default now). See https://castle-engine.io/android-Services . For iOS it is always enabled.

All the communication is asynchronous on all platforms – Pascal code sends a message, and any answers will come asynchronously later. This means that e.g. TGameService.RequestSignedIn will never call TGameService.OnStatusChanged right inside, the call to TGameService.OnStatusChanged will always happen at a later time.

This is used automatically by various engine classes like TGameService, TAds, TAnalytics, TInAppPurchases.

Hierarchy

  • TObject
  • TMessaging

Overview

Methods

Public constructor Create;
Public destructor Destroy; override;
Public procedure Send(const Strings: array of string);
Public class function BoolToStr(const Value: boolean): string;
Public class function TimeToStr(const Value: TFloatTime): string;
Public class function MessageToBoolean(const Value: String): Boolean;

Properties

Public property OnReceive: TMessageReceivedEventList read FOnReceive;
Public property Log: boolean read FLog write FLog default false;

Description

Methods

Public constructor Create;

This item has no description.

Public destructor Destroy; override;

This item has no description.

Public procedure Send(const Strings: array of string);

Send a message to a service (implemented in other language, like Java on Android or Objective-C on iOS).

Public class function BoolToStr(const Value: boolean): string;

Convert boolean to 'true' or 'false' string, which will be understood correctly by the service receiving the messages.

Public class function TimeToStr(const Value: TFloatTime): string;

Convert float time (in seconds) to integer miliseconds, which are understood correctly by the service receiving the messages.

Public class function MessageToBoolean(const Value: String): Boolean;

Convert string to a boolean, assuming the string was send by the external service. The counterpart of this in Android is ServiceAbstract.booleanToString .

Properties

Public property OnReceive: TMessageReceivedEventList read FOnReceive;

Callbacks called when new message from service is received.

Public property Log: boolean read FLog write FLog default false;

Log each message send/received from/to service. Note that this is sometimes quite verbose, and it also allows cheaters to easier debug what happens in your game (e.g. how to fake getting some achievement), so in general don't leave it "on" in production.


Generated by PasDoc 0.16.0-snapshot.