Jenkins Software

Lobby2Client_360 Overview

Interface with NP systems, including signaling

PS3 NP systems offer the concept of rooms and lobbies. Sony also hosts servers used for NAT traversal. With the use of the Lobby2Client_PS3 plugin, these services are offered through and interface with RakNet in an easier to use fashion.

The sample is located in the solution RakNet_PS3_VS2005.sln under the project np_matching2_lobby. This is the np_matching2 sample that comes with the PS3 SDK, but has been modified to interface with RakNet. If you look at the source under Lobby2Client_PS3.cpp and Lobby2Message_PS3.cpp, you'll see that much of the code is lifted right out of the sample. This is to ensure compliance with the PS3 TCRs.

Usage:

Attach an instance of Lobby2Client_PS3 to an instance of RakPeer. Most operations are performed through the SendMessage() or SendMsgAndDealloc() methods, however the class does contain some functions for utility. For example, IsInRoom() returns if you are currently in a room or not. GetNumFriends() returns the number of friends online. See the class for the full list of methods.

Available operations are found in Lobby2Message_PS3.h. The operations themselves are documented in the file. See the bottom of the file for a full list of operations.

Needed files:

All files immediately under DependentExtensions\Lobby2, except Lobby2Server.h and Lobby2Server.cpp. These are common files for all platforms.
All files immediately under DependentExtensions\Lobby2\ps3. These files are specific to the PS3.
Samples\Lobby2Client_PS3\np_matching2\np_matching2_lobby\np_conf.*

Sample code:

Init RakNet:

RakNet::Lobby2Message* startupMsg = messageFactory->Alloc(RakNet::L2MID_Client_Login);
((RakNet::Client_Login_PS3*) startupMsg)->cellSysutilRegisterCallback_slot = 3;
((RakNet::Client_Login_PS3*) startupMsg)->npCommId = NpConf::npCommId();
((RakNet::Client_Login_PS3*) startupMsg)->npCommPassphrase = NpConf::npCommPassphrase();
lobby2Client->SendMessage(startupMsg);
if (startupMsg->resultCode != RakNet::L2RC_PROCESSING && startupMsg->resultCode != RakNet::L2RC_SUCCESS)
printf("PS3 Login failed.\n");
messageFactory->Dealloc(startupMsg);

Attach plugin and register for callbacks

struct PS3Results : public RakNet::Lobby2Callbacks
{
// ...
} ps3Results;

// Attach the plugin and register the callback
messageFactory = new RakNet::Lobby2MessageFactory_PS3;
lobby2Client = new RakNet::Lobby2Client_PS3();
lobby2Client->AddCallbackInterface(&ps3Results);
lobby2Client->SetMessageFactory(messageFactory);
rakPeer->AttachPlugin(lobby2Client);

Login:

RakNet::Lobby2Message* startupMsg = messageFactory->Alloc(RakNet::L2MID_Client_Login);
((RakNet::Client_Login_PS3*) startupMsg)->cellSysutilRegisterCallback_slot = 3;
((RakNet::Client_Login_PS3*) startupMsg)->npCommId = NpConf::npCommId();
((RakNet::Client_Login_PS3*) startupMsg)->npCommPassphrase = NpConf::npCommPassphrase();
lobby2Client->SendMessage(startupMsg);
if (startupMsg->resultCode != RakNet::L2RC_PROCESSING && startupMsg->resultCode != RakNet::L2RC_SUCCESS)
{
printf("PS3 Login failed.\n");
}
messageFactory->Dealloc(startupMsg);


Read asynchronous login result:

// Update PS3Results class with this code
struct PS3Results : public RakNet::Lobby2Callbacks
{
virtual void MessageResult(RakNet::Client_Login *message)
{
if (message->resultCode == RakNet::L2RC_Client_Login_CANCELLED)
{
printf("L2RC_Client_Login_CANCELLED");
}
else if (message->resultCode == RakNet::L2RC_Client_Login_CABLE_NOT_CONNECTED)
{
printf("L2RC_Client_Login_CABLE_NOT_CONNECTED");
}
else if (message->resultCode == RakNet::L2RC_Client_Login_NET_NOT_CONNECTED)
{
printf("L2RC_Client_Login_NET_NOT_CONNECTED");
}
else if (message->resultCode != RakNet::L2RC_SUCCESS)
{
printf("An error has occurred while unloading NetStartDialog.");
}
else
{
//Success
printf("Login Success");
}
}
} ps3Results;

Important:

1. To use this system, you must start RakNet before sending the Client_Login message. Furthermore, in the SocketDescriptor passed to Startup(), you must specify remotePortRakNetWasStartedOn_PS3. If all your systems start on the same port, then SocketDescriptor::remotePortRakNetWasStartedOn_PS3 should be equal to SocketDescriptor::port.

2. When RakNet is not running, you have to call Lobby2Client_PS3::Update() manually or callbacks will not be called.

See Also

Index
PluginInterface