I found out a good way to do this. There is probably a more efficient way, but here's the code I used.
This method is called. RoomLis is then a Room listener I defined earlier.
internal bool LeaveGame()
{
MyClient.LeaveRoom(roomID); //Call leave room
for (int i = 0; i < 20; i++) //Loop a couple times. This is done to check if leave room was succesful. It can take a second.
{
if (RoomLis.GetInRoom() == true) //If still in room, sleep the thread and wait
Thread.Sleep(100);
else // else successful
return true;
}
return false; //If 2 seconds past and still haven't left, assume failure.
}
Below is the code for my room listener
internal class MyRoomListener : RoomRequestListener
{
private bool inRoom;
public bool GetInRoom()
{
return inRoom;
}
public void onJoinRoomDone(RoomEvent eventObj)
{
if (eventObj.getResult() == WarpResponseResultCode.SUCCESS)
{
Console.WriteLine("Room join success");
inRoom = true;
}
else
{
Console.WriteLine("Room join fail");
inRoom = false;
}
}
public void onLeaveRoomDone(RoomEvent eventObj)
{
if (eventObj.getResult() == WarpResponseResultCode.SUCCESS)
inRoom = false;
else
inRoom = true;
}
//... other handler code
}