示例#1
0
        public AgsClient(string host, string instance, int?port, bool useSSL, string username, string password)
        {
            bool anonymous = String.IsNullOrWhiteSpace(username);

            var builder = new UriBuilder()
            {
                Scheme = useSSL ? "https" : "http",
                Host   = host,
                Port   = port ?? 80,
                Path   = instance,
            };

            Uri baseUrl = builder.Uri;

            restSharpClient = new RestClient(baseUrl).UseSerializer(() => new JsonNetSerializer());
            restSharpClient.AddDefaultHeader("Content-Type", "application/x-www-form-urlencoded");

            if (!anonymous) // try to get a token
            {
                credentials = new Credentials {
                    username = username, password = password
                };

                //1. check if token based security available
                ServerInfoResource serverInfo = new ServerInfoRequest().Execute(this);
                if ((serverInfo.authInfo != null) && (serverInfo.authInfo.isTokenBasedSecurity))
                {
                    tokenServiceUrl = serverInfo.authInfo.tokenServicesUrl;
                    refreshToken(credentials, client_id_type, null, null, token_request_expiration_minutes);
                    useToken = true;
                }
            }
        }
示例#2
0
    public static void ResponseServerInfo(NetRequest _request)
    {
        ServerInfoRequest request = (ServerInfoRequest)_request;

        NetworkDefine.sAssetBundleDownloadUrl = request.ab_url;
        NetworkDefine.sPackageDownloadUrl     = request.package_url;

        Debug.LogError("request.version " + request.version);
        Debug.LogError("request.ab_url " + request.ab_url);
        Debug.LogError("request.package_url " + request.package_url);
        Debug.LogError("Consts.VERSION " + Consts.VERSION);

#if !UNITY_EDITOR
        if (request.version > Consts.VERSION)
        {
            // update package
            string title   = "version is too old";
            string content = "version is too old, click ok to update a new one";
            MessageBox.instance.OpenMessage(MessageBox.TYPE.Ok, title, content, OpenUrlToUpdate);
            return;
        }
#endif

        if (request._call_back != null)
        {
            request._call_back();
        }
    }
 public object Get(ServerInfoRequest request)
 {
     return(new
     {
         Result = new {
             RuntimeId = AppHost.RuntimeId,
             ServerTime = DateTime.Now,
             ServerTimeUtc = DateTime.UtcNow,
             Plugins = ServiceStackHost.Instance.Plugins.Select(p => p.GetType().FullName).ToList(),
             Routes = ServiceStackHost.Instance.RestPaths
         }
     });
 }
示例#4
0
        public void SetUp()
        {
            _input = new ServerInfoRequest
            {
                IpAddress = "127.0.0.1",
                Port      = 27960
            };
            _gameType = GameType.Quake3;

            var mapper = new ServerInfoRequestMapper();

            _result = mapper.Map(_input, _gameType);
        }
示例#5
0
        public void ServerInfo()
        {
            // Arrange
            var request = new ServerInfoRequest();

            request.Params.Add(new ServerInfoRequestParams {
            });

            // Act
            var response = _client.Server.ServerInfoAsync(request).Result;

            // Assert
            Assert.AreEqual(Status.Success, response.Result.Status);
        }
示例#6
0
        public void SampleServerAnonymousHttpConnectionTest()
        {
            string host     = "sampleserver1.arcgisonline.com";
            string instance = "arcgis";

            try
            {
                AgsClient agsClient = new AgsClient(host, instance, null, false, null, null);
                var       resp      = new ServerInfoRequest().Execute(agsClient);
                Assert.IsNull(resp.error);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
示例#7
0
    public static void RequestServerInfo(Action _callback)
    {
        ServerInfoRequest request = new ServerInfoRequest(ResponseServerInfo);

        request._call_back = _callback;

        request.deviceId = AccountInfo.instance.DeviceId;
#if UNITY_EDITOR
        request.platOS = "1";
#elif UNITY_IPHONE
        request.platOS = "2";
#elif UNITY_ANDROID
        request.platOS = "3";
#endif

        NetworkManager.instance.AddGameRequest(request, false);
    }
示例#8
0
        public async Task SetUp()
        {
            _controllerRequest = new ServerInfoRequest
            {
                IpAddress = "192.168.201.201",
                Port      = 7778
            };
            _expectedResponse = new ServerInfoDetails
            {
                HostName = "test server name"
            };

            var gameType = GameType.UnrealTournament99;

            var managerRequest = new ServerRequest
            {
                IpAddress = _controllerRequest.IpAddress,
                Port      = _controllerRequest.Port,
                GameType  = gameType
            };

            _mockServerInfoRequestMapper = new Mock <IServerInfoRequestMapper>();
            _mockServerInfoRequestMapper.Setup(m => m.Map(_controllerRequest, gameType)).Returns(managerRequest);

            _mockUnrealTournament99Manager = new Mock <IUnrealTournament99Manager>();

            _mockUnrealTournament99Manager.Setup(x => x.GetInfo(managerRequest)).Returns(Task.FromResult(_expectedResponse));

            var controller = new UnrealTournament99Controller(_mockUnrealTournament99Manager.Object, _mockServerInfoRequestMapper.Object);

            var response = await controller.GetInfo(_controllerRequest);

            var content = response as OkObjectResult;

            _actualResponse = JsonConvert.SerializeObject(content.Value);
        }
示例#9
0
        public async Task SetUp()
        {
            _controllerRequest = new ServerInfoRequest
            {
                IpAddress = "192.168.201.201",
                Port      = 27960
            };
            _expectedResponse = new ServerStatusDetails
            {
                Name = "test server name"
            };

            var gameType = GameType.Quake3;

            var managerRequest = new ServerRequest
            {
                IpAddress = _controllerRequest.IpAddress,
                Port      = _controllerRequest.Port,
                GameType  = gameType
            };

            _mockServerInfoRequestMapper = new Mock <IServerInfoRequestMapper>();
            _mockServerInfoRequestMapper.Setup(m => m.Map(_controllerRequest, gameType)).Returns(managerRequest);

            _mockQuake3Manager = new Mock <IQuake3Manager>();

            _mockQuake3Manager.Setup(x => x.GetStatus(managerRequest)).Returns(Task.FromResult(_expectedResponse));

            var controller = new Quake3ArenaController(_mockQuake3Manager.Object, _mockServerInfoRequestMapper.Object);

            var response = await controller.GetStatus(_controllerRequest);

            var content = response as OkObjectResult;

            _actualResponse = JsonConvert.SerializeObject(content.Value);
        }
示例#10
0
 public async Task <RpcJsonResponse <ServerInfoResult> > ServerInfoAsync(ServerInfoRequest request)
 {
     return(await PostAsync <RpcJsonResponse <ServerInfoResult>, ServerInfoResult>(request));
 }
示例#11
0
文件: Program.cs 项目: inwazy/Zeron
        /// <summary>
        /// Main
        /// </summary>
        /// <param name="args"></param>
        /// <returns>Returns void.</returns>
        public static void Main(string[] args)
        {
            // Core.Utils.Encryption.Encrypt("zeron.testkey");
            string clientRequestKey = "8TAoVPkmYaphto4LFTCtKw==";

            // Test Key
            Console.WriteLine(Core.Utils.Encryption.Decrypt(clientRequestKey));

            // ServerInfoRequest
            object serverInfoRequestParams = new ServerInfoRequest
            {
                APIKey = clientRequestKey
            };

            string serverInfoRequestMessage = JsonConvert.SerializeObject(serverInfoRequestParams);

            using (RequestSocket client = new RequestSocket("tcp://localhost:5589"))
            {
                client.SendFrame(serverInfoRequestMessage);

                string message = client.ReceiveFrameString();

                Console.WriteLine();
                Console.WriteLine("ServerInfoRequest : Received '{0}'", message);
            }

            // ProcessInfoRequest
            object processInfoRequestParams = new ProcessInfoRequest
            {
                APIKey = clientRequestKey
            };

            string processInfoRequestMessage = JsonConvert.SerializeObject(processInfoRequestParams);

            using (RequestSocket client = new RequestSocket("tcp://localhost:5589"))
            {
                client.SendFrame(processInfoRequestMessage);

                string message = client.ReceiveFrameString();

                Console.WriteLine();
                Console.WriteLine("ProcessInfoRequest : Received '{0}'", message);
            }

            // InstallCCleanerRequest

            /*object installCCleanerRequestParams = new InstallCCleanerRequest
             * {
             *  APIKey = clientRequestKey,
             *  Async = true
             * };
             *
             * string installCCleanerRequestMessage = JsonConvert.SerializeObject(installCCleanerRequestParams);
             *
             * using (RequestSocket client = new RequestSocket("tcp://localhost:5589"))
             * {
             *  client.SendFrame(installCCleanerRequestMessage);
             *
             *  string message = client.ReceiveFrameString();
             *
             *  Console.WriteLine();
             *  Console.WriteLine("InstallCCleanerRequest : Received '{0}'", message);
             * }*/

            // InstallDefragglerRequest

            /*object installDefragglerRequestParams = new InstallDefragglerRequest
             * {
             *  APIKey = clientRequestKey,
             *  Async = true
             * };
             *
             * string installDefragglerRequestMessage = JsonConvert.SerializeObject(installDefragglerRequestParams);
             *
             * using (RequestSocket client = new RequestSocket("tcp://localhost:5589"))
             * {
             *  client.SendFrame(installDefragglerRequestMessage);
             *
             *  string message = client.ReceiveFrameString();
             *
             *  Console.WriteLine();
             *  Console.WriteLine("InstallDefragglerRequest : Received '{0}'", message);
             * }*/

            // InstallGitRequest

            /*object installGitRequestParams = new InstallGitRequest
             * {
             *  APIKey = clientRequestKey,
             *  Async = true
             * };
             *
             * string installGitRequestMessage = JsonConvert.SerializeObject(installGitRequestParams);
             *
             * using (RequestSocket client = new RequestSocket("tcp://localhost:5589"))
             * {
             *  client.SendFrame(installGitRequestMessage);
             *
             *  string message = client.ReceiveFrameString();
             *
             *  Console.WriteLine();
             *  Console.WriteLine("InstallGitRequest : Received '{0}'", message);
             * }*/

            // Install7ZipRequest

            /*object install7ZipRequestParams = new Install7ZipRequest
             * {
             *  APIKey = clientRequestKey,
             *  Async = true
             * };
             *
             * string install7ZipRequestMessage = JsonConvert.SerializeObject(install7ZipRequestParams);
             *
             * using (RequestSocket client = new RequestSocket("tcp://localhost:5589"))
             * {
             *  client.SendFrame(install7ZipRequestMessage);
             *
             *  string message = client.ReceiveFrameString();
             *
             *  Console.WriteLine();
             *  Console.WriteLine("Install7ZipRequest : Received '{0}'", message);
             * }*/

            // InstallKLiteRequest

            /*object installKLiteRequestParams = new InstallKLiteRequest
             * {
             *  APIKey = clientRequestKey,
             *  Async = true
             * };
             *
             * string installKLiteRequestMessage = JsonConvert.SerializeObject(installKLiteRequestParams);
             *
             * using (RequestSocket client = new RequestSocket("tcp://localhost:5589"))
             * {
             *  client.SendFrame(installKLiteRequestMessage);
             *
             *  string message = client.ReceiveFrameString();
             *
             *  Console.WriteLine();
             *  Console.WriteLine("InstallKLiteRequest : Received '{0}'", message);
             * }*/

            // InstallFirefoxRequest

            /*object installFirefoxRequestParams = new InstallFirefoxRequest
             * {
             *  APIKey = clientRequestKey,
             *  Async = true
             * };
             *
             * string installFirefoxRequestMessage = JsonConvert.SerializeObject(installFirefoxRequestParams);
             *
             * using (RequestSocket client = new RequestSocket("tcp://localhost:5589"))
             * {
             *  client.SendFrame(installFirefoxRequestMessage);
             *
             *  string message = client.ReceiveFrameString();
             *
             *  Console.WriteLine();
             *  Console.WriteLine("InstallFirefoxRequest : Received '{0}'", message);
             * }*/

            Console.ReadKey();
        }