Photon C++ Client API 126.96.36.199
When a PhotonPeer instance is created, the PhotonPeer is ready to connect to a Photon Server. To do that, call the function connect()
After initializing the connection, the application should wait for the onStatusChanged() callback function. If its returnCode is StatusCode::CONNECT, the connection has been established.
As soon as the client application is connected to Photon, use the function opJoin() to join or create a game. If there is no game with the given identifier, a new game will be created. If the call succeeds, the onOperationResponse() callback will be called with operation code OPC_RT_JOIN, and also an event will be raised, resulting in a call to onEvent() callback with event code EV_RT_JOIN .
In addition to the events raised by Photon you can also define and raise events needed for your game. E.g. you could define a event named "EV_SHOOT" to broadcast the information that the local actor has just fired a weapon at the position stored in the variables pMe->fireX, pMe->fireY. First pick and define an operation code for your "shoot" event. Make sure it won't collide with the Event codes #defined in PhotonConstants.h
To keep your code more readable and maintainable, you should also define key codes for your corresponding Hashtable entries, as shown below:
In the game we can now create an Hashtable for the shoot event and include the fire-coordinates as Key/Value pairs.
As soon as Photon has delivered this operation, the onEvent() callback will be called at all the other players inside the same room, with event code beeing EV_SHOOT. Use a switch case on the event code to handle the different events accordingly.
Use the opLeave() function to leave the currently joined room.
It sends an operation to the server and other players will receive the event EV_RT_LEAVE. When the operation is completed successfully, the ExitGames::Photon::PhotonListener::onOperationResponse() callback will be called at the local peer with the opCode OPC_RT_LEAVE.
Disconnecting should be done using disconnect().
When disconnecting is finished, the onStatusChanged() callback will be called and the status code should be StatusCode::DISCONNECT.