How to get Room status?

All Union Platform questions, comments, feature requests, and bug reports.

How to get Room status?

Postby divyaaditya91 » Sun 26 Oct 2014 08:11

I have a flash multi player game in which the room has max clients 2. Now if another (3rd, 4th, 5th.....) client comes i want to make him spectator of the current game.
I did this -
i created a room attribute named "status", and wanted to read the "status" value when a client connects to union server. But when I try to read the value it returns null but in UnionAdmin, it is showing the room attribute and the clients. Just have problem in reading the "status" from flash client. Please help!

TableRoom = reactor.getRoomManager().getRoom("chatRoom");



if(!TableRoom) //if does not exists then create
{
settings = new RoomSettings();
settings.removeOnEmpty = false;
settings.maxClients = 2;

var modules:RoomModules = new RoomModules();
modules.addModule("net.user1.union.example.roommodule.ChessModule", ModuleType.CLASS);
TableRoom = reactor.getRoomManager().createRoom("chatRoom", settings, null, modules);
}



TableRoom.addMessageListener("CHAT_MESSAGE", chatMessageListener);//output in textarea
TableRoom.addMessageListener("START_GAME", startGameListener);
TableRoom.addEventListener(AttributeEvent.UPDATE, updateRoomAttributeListener);




var status:String = TableRoom.getAttribute("STATUS");

trace(status);
divyaaditya91
 
Posts: 3
Joined: Sun 26 Oct 2014 08:03

Return to Union Platform

Online

Users browsing this forum: No registered users and 4 guests