Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        public Task SignalGameStarted(string gameId)
        {
            var packet = new RequestPacket(nameof(IClientHostingRPC.SignalGameStarted));

            HostedGame.AddIdToPacket(packet, gameId);

            return(_client.Connection.Request(packet));
        }
Exemplo n.º 3
0
        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>());
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
 public static void AddToPacket(DictionaryPacket packet, HostedGame game)
 {
     packet["hostedgame"] = game;
 }
Exemplo n.º 7
0
 public static Task <HostedGame> HostGame(this Client client, HostedGame game)
 {
     return(client.Hosting().RPC.HostGame(game));
 }