public static Task <HostedGame> HostGame(this Client client, HostedGame game) { if (client == null) { throw new ArgumentNullException(nameof(client)); } if (game == null) { throw new ArgumentNullException(nameof(game)); } var hosting = client.Hosting(); if (hosting == null) { throw new InvalidOperationException($"{nameof(Octgn.Online.Hosting.Hosting)} module not registered for {nameof(Client)} {client}"); } if (hosting.ClientRPC == null) { throw new InvalidOperationException($"{nameof(Octgn.Online.Hosting.Hosting)} module not configured correctly for {nameof(Client)} {client}"); } return(hosting.ClientRPC.HostGame(game)); }
public Task SignalGameStarted(string gameId) { var packet = new RequestPacket(nameof(IClientHostingRPC.SignalGameStarted)); HostedGame.AddIdToPacket(packet, gameId); return(_client.Connection.Request(packet)); }
public async Task <HostedGame> HostGame(HostedGame game) { var packet = new RequestPacket(nameof(IClientHostingRPC.HostGame)); game.OctgnVersion = _octgnVersion.ToString(); HostedGame.AddToPacket(packet, game); var result = await _client.Connection.Request(packet); return(result.As <HostedGame>()); }
public static string Serialize(HostedGame hostedGame) { if (hostedGame == null) { throw new ArgumentNullException(nameof(hostedGame)); } var hostedGameJson = JsonConvert.SerializeObject(hostedGame); var hostedGameBytes = Encoding.UTF8.GetBytes(hostedGameJson); return(Convert.ToBase64String(hostedGameBytes)); }
public HostedGame(HostedGame game, bool includeSensitiveData) { Id = game.Id; Name = game.Name; HostUser = game.HostUser; GameId = game.GameId; GameName = game.GameName; GameVersion = game.GameVersion; OctgnVersion = game.OctgnVersion; HasPassword = game.HasPassword; Spectators = game.Spectators; GameIconUrl = game.GameIconUrl; HostUserIconUrl = game.HostUserIconUrl; HostAddress = game.HostAddress; Status = game.Status; Source = game.Source; DateCreated = game.DateCreated; DateStarted = game.DateStarted; Password = includeSensitiveData ? game.Password : string.Empty; ProcessId = includeSensitiveData ? game.ProcessId : 0; }
public static void AddToPacket(DictionaryPacket packet, HostedGame game) { packet["hostedgame"] = game; }
public static Task <HostedGame> HostGame(this Client client, HostedGame game) { return(client.Hosting().RPC.HostGame(game)); }