Photon C++ Client API: PhotonListener Class Reference

Photon C++ Client API

Photon C++ Client API  4.1.12.2
PhotonListener Class Referenceabstract
Inheritance diagram for PhotonListener:
Collaboration diagram for PhotonListener:

Public Member Functions

virtual ~PhotonListener (void)
 
virtual void onOperationResponse (const OperationResponse &operationResponse)=0
 
virtual void onStatusChanged (int statusCode)=0
 
virtual void onEvent (const EventData &eventData)=0
 
virtual void onPingResponse (const Common::JString &address, unsigned int pingResult)
 
- Public Member Functions inherited from BaseListener
virtual void debugReturn (int debugLevel, const JString &string)=0
 

Constructor & Destructor Documentation

§ ~PhotonListener()

virtual ~PhotonListener ( void  )
virtual

Destructor.

Member Function Documentation

§ onOperationResponse()

virtual void onOperationResponse ( const OperationResponse operationResponse)
pure virtual

This function gets called by the library as callback to operations in response to operations sent to the Photon Server providing the response values from the server.

This callback is used as general callback for all operations. The type of an operation is identified by an operation code.

An operation's response is summarized by the return code: an int typed code, 0 for OK or some error code defined by the application, which is defining the operation itself. The opCode defines the type of operation called on Photon and in turn also the return values. They are provided as a Hashtable which contains the complete reponse of Photon, including keys for operation code and return code. Each operation returns its opCode and returnCode but anything else can be defined serverside.

Parameters
operationResponsethe OperationResponse

§ onStatusChanged()

virtual void onStatusChanged ( int  statusCode)
pure virtual

onStatusChanged is used to denote errors or simply state-changes of the respective PhotonPeer.

State change callback

When this function is used to signalize a state-change, the statusCode will be one of these: StatusCode::CONNECT the connection to the Photon Server was established StatusCode::DISCONNECT the connection was closed (due to an API-call or a timeout)

Furthermore this function will be called by Photon to inform about connection errors and warnings. Check StatusCode.h for a list.

Parameters
statusCodesee description

§ onEvent()

virtual void onEvent ( const EventData eventData)
pure virtual

This is the event handler function for all Events transmitted by PhotonPeer.

Whenever a Photon event is sent and received, the receiving peer will be notified via this function. Please refer to Sending and receiving data for more information.

This way, an application can react on any event, based on its event code.

The following events are reported by default: EV_RT_JOIN EV_RT_LEAVE

These events are predefined and will be triggered as soon as a player has joined or has left the room in which the local player is currently active in. To transmit in-room data, define your own events as needed for your application, and transmit them using LitePeer::opRaiseEvent().

All events which are raised in reaction to some player's actions (like sending data) contain the actor number of the sending player in the "parameters" Hashtable.

If the received event has been raised by another player by calling LitePeer::opRaiseEvent(), the transmitted payload hashtable will be stored in the "parameters" hashtable of at key EV_RT_KEY_DATA. Please refer to the demos for sample code.

Parameters
eventDatathe EventData
See also
Sending and receiving data, LitePeer::opRaiseEvent()

§ onPingResponse()

virtual void onPingResponse ( const Common::JString address,
unsigned int  pingResult 
)
virtual

This is the callback for PhotonPeer::pingServer().

Each ping signal that has been sent through PhotonPeer::pingServer() results in a call to this function, providing the address to which the ping has been sent and the time in milliseconds that has passed between sending the ping and receiving the servers response.

Note
: This function is not available on platforms that do not support those parts of the stdlib that have been introduced with C++ 11.
: Also this function is not available on platforms that do not support multithreading.
Parameters
addressthe address, which has been pinged
pingResultthe time in ms
See also
PhotonPeer::pingServer()