Skip to content

Instantly share code, notes, and snippets.

@TokyoDan
Created August 27, 2013 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TokyoDan/6352445 to your computer and use it in GitHub Desktop.
Save TokyoDan/6352445 to your computer and use it in GitHub Desktop.
onGetAllRoomsDone
public void onGetAllRoomsDone (AllRoomsEvent eventObj)
{
//Log ("onGetAllRoomsDone : " + eventObj.getResult());
byte rslt = eventObj.getResult();
if(rslt == 0)
{
string[] roomIds = eventObj.getRoomIds();
if( roomIds.Length == 1 )
{
TOTlog("2 onGetAllRoomsDone because you called GetAllRooms(): Only default room so we are creating a new one");
Dictionary<string, object> roomProps = new Dictionary<string, object>();
roomProps.Add("Blue", "empty");
roomProps.Add("Red", "empty");
roomProps.Add("Green", "empty");
roomProps.Add("Orange", "empty");
int reqNumOfPlyrs = TOTmatch.reqNumberOfPlayers;
// int reqNumOfPlyrs = GameObject.Find("StartupTOT").GetComponent<TOTmatch>().reqNumberOfPlayers;
TOTlog("2 onGetAllRoomsDone: creating a room with " + reqNumOfPlyrs + " players");
// CreateRoom() will cause onCreateRoomDone() to be called in which we will
// SubscribeRoom() which will cause onSubscribeRoomDone() to be called in which we will JoinRoom()..
WarpClient.GetInstance().CreateRoom(TOTmatchMaker.aRoomRandomName, TOTmatchMaker.myUserName, reqNumOfPlyrs, roomProps);
}
else
{
// Don't subscribe to default static romm = roomIds[0]. Join the 2nd room.
TOTlog("2 onGetAllRoomsDone because you called GetAllRooms(): Got not-default room ID " + roomIds[1] + " so we are subscribing to it");
// SubscribeRoom() will cause onSubscribeRoomDone() to be called in which we will JoinRoom().
WarpClient.GetInstance().SubscribeRoom(roomIds[1]);
}
}
else
{
TOTlog("2 onGetAllRoomsDone (because you called GetAllRooms). Request Failure: " + rslt);
}
}
public void onGetMatchedRoomsDone(MatchedRoomsEvent eventObj)
{
byte rslt = eventObj.getResult();
if (rslt == WarpResponseResultCode.SUCCESS)
{
TOTlog("GetMatchedRooms event received with success status");
foreach (var roomData in eventObj.getRoomsData())
{
TOTlog("Room ID:" + roomData.getId());
}
}
else
{
TOTlog("GetMatchedRooms event received with failed status: " + rslt);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment