public class MyGameRoom extends Room {
public class MyGameRoom implements RoomListener {
private RoomServices m_roomServices; // RoomServices for this Room
public void onRoomInit(RoomServices roomServices) {
// --- save the RoomServices reference
m_roomServices = roomServices;
// rest of your code goes here
}
| Unity 1.x | Unity 2 Multiuser Server |
| killClient(Client client) | Services.getClientServices(String clientID).killClient() |
| killClient(int clientID) | Services.getClientServices(String clientID).killClient() |
| killRoom() | m_roomServices.killRoom() |
| killRoom(String roomID) | Services.getRoomManagementServices.killRoom(String roomID) |
| isDying() | m_roomServices.isDying() |
| getNumClients() | m_roomServices.getNumClients() |
| getNumClients(String roomID) | Services.getRoomServices(roomID).getNumClients() |
| broadcastRoom(*) | m_roomServices.broadcastRoom(String message) |
| broadcastRoomButClient(*) | m_roomServices.broadcastRoomButClient(String clientID, String message) |
| broadcastClient(*) | Services.getClientServices().broadcastClient(String message) |
| pauseRoom(long pause) | Deleted. Rooms are responsible for setting up their own additional threads. See this tutorial for an example. |
| getRoom(String roomID) | Services.getRoomServices(String roomID) |
| getRoomID() | m_roomServices.getRoomID() |
| getSentryID() | Deleted. Unity 2.x no longer uses Room Sentries for authentication. |
| getClientList() | m_roomServices.getClientList() |
| getClientListButClient(Client butClient) | Deleted. Use m_roomServices.getClientList() and simply remove the clientID(s) not wanted. |
| changeRoom(*) | Deleted. Use Services.getClientServices(clientID).leaveRoom(oldRoomID) and Services.getClientServices(clientID).joinRoom(newRoomID) |
| broadcastRoom(String roomid, String message) | Services.getRoomServices(roomID).broadcastRoom(String message) |
| getRoomNames() | Services.getRoomManagementServices.getRoomList() |
| getMaxClients() | m_RoomServices.getRoomProperties().getMaxClients() |
| getProperty(String name) | m_RoomServices.getAttribute(String name) |
| setProperty(String name, String value) | m_RoomServices.setAttribute(String name, String value) |
| spawnRoom(RoomProperties props) | Services.getRoomManagementServices().spawnRoom(RoomDefinition def) |
<MESSAGE TYPE="broadcastText" FROM="client">
<TEXT>Hi There!</TEXT>
</MESSAGE>
It contains all of the parts of a UPC Message. It has a Method, or Type, broadcastText, and it contains arguments, in this
case 1 argument the Text to send or "Hi There!"
<UPC>
<ROOMID>chatRoom05</ROOMID>
<METH>broadcastText</METH>
<ARGS>
<ARG>Hi There!</ARG>
</ARGS>
</UPC>
UPC is both more structured and more generic. U2MS also comes with Classes that allow you
to quickly build and parse UPC as well as treat a UPC Message as an Object. For example to create
this Message in Java you would use the following code: