Add error message when creation fails

This commit is contained in:
smoogipoo
2018-12-26 18:38:58 +09:00
parent 052ab4763a
commit be9ba78d47
7 changed files with 109 additions and 16 deletions

View File

@ -42,13 +42,19 @@ namespace osu.Game.Screens.Multi
TimeBetweenPolls = 5000;
}
public void CreateRoom(Room room)
public void CreateRoom(Room room, Action<string> onError = null)
{
room.Host.Value = api.LocalUser;
var req = new CreateRoomRequest(room);
req.Success += result => addRoom(room, result);
req.Failure += exception => Logger.Log($"Failed to create room: {exception}");
req.Failure += exception =>
{
if (req.Result != null)
onError?.Invoke(req.Result.Error);
else
Logger.Log($"Failed to create the room: {exception}", level: LogLevel.Important);
};
api.Queue(req);
}