Esempio n. 1
0
 public GameServer(PlayerEnvironment playerEnvironment)
 {
     _tcpConnection = new TcpConnection();
     _host          = playerEnvironment.Host;
     _port          = playerEnvironment.Port;
     _envName       = playerEnvironment.Name;
 }
Esempio n. 2
0
        static async Task DoYourThing()
        {
            PlayerEnvironment environment = PlayerEnvironment.GetCurrentEnvironment();
            GameServer        server      = new GameServer(environment);

            // Register event handlers
            server.SetOnMsgSentEvent((bytes, offset, count) => Console.WriteLine("-> " + Encoding.UTF8.GetString(bytes, offset, count)));
            server.SetOnMsgReceivedEvent((bytes, offset, count) => Console.WriteLine("<- " + Encoding.UTF8.GetString(bytes, offset, count)));
            server.SetOnConnectedEvent(b => Console.WriteLine("Connected"));
            server.SetOnConnectionClosedEvent(s => Console.WriteLine("Disconnected. Reason: " + s));

            // Connect to server
            Console.WriteLine("Connecting to server...");
            await server.ConnectTask();

            // Authenticate user
            JsonRpcResponse response = await server.AuthenticateAsyncTask(_ticket);

            Console.WriteLine("Session id: " + response.result.GetPayloadValue <string>("sessionId"));

            response = await server.PingAsyncTask();

            Console.WriteLine(response.result.GetPayloadValue());

            response = await server.DerpAsyncTask();

            Console.WriteLine(response.error.message);
        }
Esempio n. 3
0
        static async Task RedeemCodes(string codesList)
        {
            try
            {
                await Login();

                var server = new GameServer(await PlayerEnvironment.GetDefaultEnvironmentAsyncTask());
                await server.ConnectTask();

                await server.AuthenticateAsyncTask(_ticket);

                using (StreamReader sr = new StreamReader(codesList))
                {
                    while (!sr.EndOfStream)
                    {
                        string code = sr.ReadLine();

                        var response = await server.RedeemCodeAsyncTask(_ticket, code);

                        if (response.result != null)
                        {
                            RedeemSuccess(code);
                        }
                        else
                        {
                            RedeemFailure(code);
                        }
                    }
                }

                ShowSummary();
            }
            catch (Exception ex)
            {
                Console.WriteLine("[!] Unexpected error: " + ex.Message + ", " + ex.StackTrace);
            }
        }
Esempio n. 4
0
 public MtgAPI(PlayerEnvironment playerEnvironment)
 {
     _url                 = "https://api.platform.wizards.com";
     _accountSystemId     = playerEnvironment.ClientId;
     _accountSystemSecret = playerEnvironment.ClientSecret;
 }