public ContentResult AcceptInvite(Guid?inviteGuid) { if (!inviteGuid.HasValue) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Content("Wrong invite Guid", MediaTypeNames.Text.Plain)); } MatchInvite invite = MatchManager.Instance.MatchInvites.Where(i => i.Id == inviteGuid.Value).FirstOrDefault(); if (invite == null) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Content("Wrong invite Guid", MediaTypeNames.Text.Plain)); } try { MatchManager.Instance.UserJoinLobby(CurrentUser.Instance.Current, invite.MatchId); } catch (LobbyJoinException) { //todo: handle exceptions properly Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Content("Can't join lobby", MediaTypeNames.Text.Plain)); } finally { MatchManager.Instance.MatchInvites.Remove(invite); } return(Content("success")); }
public ActionResult RenderInvite(Guid?inviteGuid) { if (!inviteGuid.HasValue) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(new EmptyResult()); } MatchInvite invite = MatchManager.Instance.MatchInvites.Where(i => i.Id == inviteGuid.Value).FirstOrDefault(); return(PartialView(invite)); }
public ContentResult DenyInvite(Guid?inviteGuid) { if (!inviteGuid.HasValue) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Content("Wrong invite Guid", MediaTypeNames.Text.Plain)); } MatchInvite invite = MatchManager.Instance.MatchInvites.Where(i => i.Id == inviteGuid.Value).FirstOrDefault(); if (invite == null) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Content("Wrong invite Guid", MediaTypeNames.Text.Plain)); } MatchManager.Instance.MatchInvites.Remove(invite); return(Content("success")); }
public ContentResult InvitePlayer(Guid?playerGuid) { if (!playerGuid.HasValue) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Content("Wrong user Guid", MediaTypeNames.Text.Plain)); } MatchInvite invite = MatchManager.Instance.InviteUserToLobby(CurrentUser.Instance.Current, playerGuid.Value); if (invite == null) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Content("Can't invite player to lobby", MediaTypeNames.Text.Plain)); } else { Longpool.Instance.PushMessageToUser(playerGuid.Value, new AsyncMessage(invite)); return(Content("success")); } }
public MatchInvite InviteUserToLobby(User invitingUser, Guid userToInviteId) { Match lobby = MatchManager.Instance.FindMatchByParticipantID(invitingUser.Id, true); if (lobby == null) return null; MatchInvite invite = new MatchInvite(lobby.Id, invitingUser, userToInviteId); MatchManager.Instance.MatchInvites.Add(invite); return invite; }
public AsyncMessage(MatchInvite invite) { Type = MessageType.Invite; Data = invite; }
public AsyncMessage(MatchInvite invite) { Type = MessageType.Invite; Data = invite; }