示例#1
0
 /// <summary>
 /// 清理关闭控制器
 /// </summary>
 public void Dispose()
 {
     PathManager.Instance.Dispose();
     AssetManager.Instance.Dispose();
     GameEnvironment.Instance.Dispose();
     SocketManager.Instance.Dispose();
     AudioManager.Instance.Dispose();
     UIManager.Instance.Dispose();
     WebImageManager.Instance.Dispose();
     InputManager.Instance.Dispose();
     DownLoadManager.Instance.Dispose();
     ObjectPoolManager.Instance.Dispose();
     HotFixManager.Instance.Dispose();
     GameSceneManager.Instance.Dispose();
     TimerManager.Instance.Dispose();
     GameStateChecker.Instance.Dispose();
     GameUtils.Instance.Dispose();
     NotificationCenter.Instance.Dispose();
     GameLooper.Instance.Dispose();
     GameFactory.Instance.Dispose();
     HTTPManager.OnQuit();
     MemoryClear();
     Destroy(gameObject);
     Instance = null;
 }
示例#2
0
        /// <summary>
        /// Send a tcp message
        /// </summary>
        /// <param name="httpViewModel"></param>
        /// <returns></returns>
        /// <remarks>
        /// Test URLs
        /// http://httpbin.org/robots.txt
        /// http://httpbin.org/get
        /// http://httpbin.org/post
        /// </remarks>
        public ActionResult SendTcpMessage(HttpViewModel httpViewModel)
        {
            if (httpViewModel == null)
            {
                throw new ArgumentNullException(nameof(HttpViewModel));
            }

            Uri  uriResult;
            bool result = Uri.TryCreate(httpViewModel.HttpRequest, UriKind.Absolute, out uriResult) &&
                          (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);

            if (!result)
            {
                httpViewModel.HttpResponse = "Not a valid URL";

                return(PartialView("_HttpResponse", httpViewModel));
            }

            string response = "";

            if (httpViewModel.HttpRequestType == HttpRequestType.Get)
            {
                response = HTTPManager.SendGetRequest(httpViewModel.HttpRequest);
            }
            if (httpViewModel.HttpRequestType == HttpRequestType.Post)
            {
                response = HTTPManager.SendPostRequest(httpViewModel.HttpRequest);
            }

            httpViewModel.HttpResponse = response;

            return(PartialView("_HttpResponse", httpViewModel));
        }
示例#3
0
        public void RequestAdSources(List <string> zoneIds = null)
        {
            if (_requestingAdSources)
            {
                return;
            }
            _requestingAdSources = true;
            string adSourcesRequestUrl = Settings.mediationEndpoint + "/v1/games/" + Engine.Instance.AppId + "/adSources";

            //string adSourcesRequestUrl = Settings.serverEndpoint + "/testAdSources.json";

            adSourcesRequestUrl = Utils.addUrlParameters(adSourcesRequestUrl, new Dictionary <string, object>()
            {
                { "zones", zoneIds != null ? String.Join(",", zoneIds.ToArray()) : null },
                { "config", configId }
            });

            HTTPRequest request = new HTTPRequest("POST", adSourcesRequestUrl);

            request.addHeader("Content-Type", "application/json");
            string payload = MiniJSON.Json.Serialize(new Dictionary <string, object>()
            {
                { "lastServerTimestamp", ConfigManager.Instance.serverTimestamp },
                { "adTimes", ZoneManager.Instance.GetConsumeTimes(ConfigManager.Instance.serverTimestamp) }
            });

            request.setPayload(payload);

            Utils.LogDebug("Requesting new ad sources from " + adSourcesRequestUrl + " with payload: " + payload);
            Event.EventManager.sendMediationAdSourcesEvent(Engine.Instance.AppId);
            HTTPManager.sendRequest(request, HandleAdSourcesResponse, retryDelays, 20 * 60);
        }
示例#4
0
    // Use this for initialization
    void Start()
    {
        userData = GetComponent<HTTPManager>();

        // 처음 접속이라면
        if (!PlayerPrefs.HasKey("firstAccess"))
        {
            string code = userCode.HTTP_REQUEST();
            if (code == "error")
            {
                Debug.Log("Get Code Error!");
            }
            else
            {
                // 유저 코드를 받아온다.
                PlayerPrefs.SetString("UserCode", code);
                Debug.Log("Code : " + PlayerPrefs.GetString("UserCode"));

                nickNameUI.ChangeActive(UIState.normal, UIState.empty);
            }
        }
        // 접속 기록이 있다면
        else
        {
            Application.LoadLevel("Main");
        }
    }
示例#5
0
    // HQ가 파괴되었다는 패킷 수신 함수
    public void OnReceiveGameFinishPacket(PacketId id, byte[] data)
    {
        GameFinishPacket packet     = new GameFinishPacket(data);
        GameFinishData   winnerData = packet.GetPacket();

        HTTPManager httpManager = new HTTPManager();
        UserInfo    userInfo    = GameObject.Find("DataObject").GetComponent <UserInfo>();

        bool win = userInfo.userData.playerCamp == winnerData.winnerCamp;

        httpManager.UpdateUserWinReq(userInfo.userData.id, win);

        UIManager.instance.ActivateGameEnd(win);

        // 서버에 보낼 게임 정보 업데이트
        userInfo.userPlayData.achievescore = 0;
        userInfo.userPlayData.victory      = 0;
        userInfo.userPlayData.lose         = 0;
        userInfo.userPlayData.death        = 1;
        userInfo.userPlayData.imageid      = 0;

        userInfo.userPlayData.kill   = killCount;
        userInfo.userPlayData.damage = (int)damageCount;

        // Flask 서버에 업적 업데이트 및 점수 업데이트.
        httpManager.UpdateAchieveReq(userInfo.userData.id, userInfo.userPlayData);

        // n 초 뒤에 로비씬으로 이동.
        StartCoroutine(GoBackToLobby());
    }
        private void Initialize()
        {
            var fileContent   = ReadFile(@"C:\Users\12353\Desktop\bachelor\SV\HttpListener\protocolConfig.json");
            var configuration = JsonConvert.DeserializeObject <Content>(fileContent);

            foreach (var c in configuration.PortConfig)
            {
                switch (c.Type)
                {
                case "UDP":
                    UDPManager uDPManager = new UDPManager(new DBHandler("udp_messages"));
                    uDPManager.Manage();
                    break;

                case "AMQP":
                    AMQPManager aMQPManager = new AMQPManager(new DBHandler("amqp_messages"));
                    aMQPManager.Manage();
                    break;

                default:
                    HTTPManager hTTPManager = new HTTPManager(new DBHandler("request_responses"));
                    hTTPManager.Manage();
                    break;
                }
            }
        }
示例#7
0
        internal static void SetupCacheFolder()
        {
            if (!HTTPCacheService.IsSupported)
            {
                return;
            }

            try
            {
                if (string.IsNullOrEmpty(CacheFolder) || string.IsNullOrEmpty(LibraryPath))
                {
                    CacheFolder = System.IO.Path.Combine(HTTPManager.GetRootCacheFolder(), "HTTPCache");
                    if (!Directory.Exists(CacheFolder))
                    {
                        Directory.CreateDirectory(CacheFolder);
                    }

                    LibraryPath = System.IO.Path.Combine(HTTPManager.GetRootCacheFolder(), "Library");
                }
            }
            catch
            {
                isSupported = false;

                HTTPManager.Logger.Warning("HTTPCacheService", "Cache Service Disabled!");
            }
        }
示例#8
0
    public void HttpRequestByMothdType(HTTPMethods methodType, string param, bool isKeepAlive, bool disableCache, Action <int, string, string> callBack)
    {
        string url = BaseUrl + SubPath + param;

        HTTPManager.SendRequest(url, methodType, isKeepAlive, disableCache, (HTTPRequest originalRequest, HTTPResponse response) =>
        {
            if (response == null)
            {
                callBack(-1, "", "");
                return;
            }
            string responseStr = "";
            int result         = 0;
            string msg         = "";
            if (response.IsSuccess)
            {
                responseStr = Encoding.UTF8.GetString(response.Data);
            }
            else
            {
                result = response.StatusCode;
                msg    = response.Message;
            }
            if (callBack != null)
            {
                callBack(result, msg, responseStr);
            }
        });
    }
示例#9
0
 public void HttpPostUrlRequest(string url, Action <int, string, string> callBack)
 {
     Debug.Log("请求:" + url);
     HTTPManager.SendRequest(url, HTTPMethods.Post, (HTTPRequest originalRequest, HTTPResponse response) => {
         if (response == null)
         {
             callBack(-1, "", "");
             return;
         }
         string responseStr = "";
         int result         = 0;
         string msg         = "";
         if (response.IsSuccess)
         {
             responseStr = Encoding.UTF8.GetString(response.Data);
         }
         else
         {
             result = response.StatusCode;
             msg    = response.Message;
         }
         if (callBack != null)
         {
             Debug.Log("错误码:" + result + " 返回:" + msg);
             Debug.Log("responseStr:" + responseStr);
             callBack(result, msg, responseStr);
         }
     });
 }
示例#10
0
        /// <summary>
        /// Record a Udp message
        /// </summary>
        /// <returns></returns>
        /// <remarks>50002</remarks>
        public ActionResult RecordUDPMessage(HttpViewModel httpViewModel)
        {
            httpViewModel.HttpResponse = HTTPManager.ReceiveUdpBroadcast(httpViewModel.HttpPortNumber);

            SensorProcessing.RecordData(httpViewModel);

            return(PartialView("_HttpResponse", httpViewModel));
        }
示例#11
0
 public void StartDownloadTexture()
 {
     if (getTextureStarted || texture != null)
     {
         return;
     }
     HTTPManager.SendRequest(avatar_url, OnUserAvatarDownloaded);
 }
示例#12
0
 private void Start()
 {
     userInfo    = GameObject.Find("DataObject").GetComponent <UserInfo>();
     httpManager = new HTTPManager();
     apiManager  = new APIManager();
     infoText.SetActive(false);
     SoundManager.instance.PlayBGM("Login_BGM", .4f);
 }
示例#13
0
        private bool OnApplicationQuitting()
        {
            this.isApplicationShuttingDown = true;
            this.DestoryConnection();

            HTTPManager.OnUpdate();

            return(true);
        }
        private void CreatePDF(string json, Documento doc, Configuracion conf)
        {
            string jsonTemplate = "{ \"template\": { \"name\" : \"timbrado_rpt\" },\"data\" : " + json + "}";

            HTTPManager pdf = new HTTPManager();

            pdf.RequestPDF(conf.ReportUrl, jsonTemplate, doc.RutaArchivoPDF);
            WriteLog("Archivo PDF Creado para:" + doc.NombreXml);
        }
示例#15
0
    /// <summary>
    /// Download the latest version number on Github.</summary>
    /// <param name="action">Callback when version number has been downloaded (not called in case of error).</param>
    public static void GetLatestVersionAsync(Action action)
    {
        // check here for official release
        string url = "https://raw.githubusercontent.com/NPBruce/valkyrie/master/unity/Assets/Resources/version.txt";

        version_downloaded_action = action;

        HTTPManager.Get(url, GetLatestVersion_callback);
    }
示例#16
0
        internal void CloseStream()
        {
            var conn = HTTPManager.GetConnectionWith(this.baseRequest);

            if (conn != null)
            {
                conn.Abort(HTTPConnectionStates.Closed);
            }
        }
示例#17
0
    /// <summary>
    /// Download required files then draw screen
    /// </summary>
    void Start()
    {
        new LoadingScreen(new StringKey("val", "DOWNLOAD_LIST").Translate());
        game         = Game.Get();
        remoteQuests = new List <RemoteQuest>();
        string remoteManifest = GetServerLocation() + "manifest.ini";

        HTTPManager.Get(remoteManifest, DownloadManifest_callback);
    }
示例#18
0
    void Start()
    {
        httpManager = new HTTPManager();
        userInfo    = GameObject.Find("DataObject").GetComponent <UserInfo>();
        socket      = GetComponent <TransportTCP>();
        Debug.Log("유저 : " + userInfo.userData.token);
        socket.Connect(address, port);

        // StartCoroutine(ChatTest());
    }
        private void SendPost(string _subUrl, Dictionary <string, string> _kvs)
        {
            HTTPRequest _request = HTTPManager.SendRequest(_subUrl, HTTPMethods.Post, true, true, OnResponse);

            foreach (System.Collections.Generic.KeyValuePair <string, string> _kvp in _kvs)
            {
                _request.AddField(_kvp.Key, _kvp.Value);
            }
            _request.Send();
        }
示例#20
0
    public void StartDownload()
    {
        Debug.Log("Yes");
        var request = new HTTPRequest(new Uri(Spath), OnfragmentDownloaded);

        request.OnProgress         = OnDownloadProgress;
        request.UseStreaming       = true;
        request.StreamFragmentSize = 1024;
        HTTPManager.SendRequest(request);
    }
示例#21
0
    // Start is called before the first frame update
    void Start()
    {
        httpManager = new HTTPManager();
        userInfo    = GameObject.Find("DataObject").GetComponent <UserInfo>();
        Debug.Log("유저 : " + userInfo.userData.token);
        // 서버에 접속

        // 통신 스레드 시작. Thread를 쓸 것이냐, Coroutine을 쓸 것이냐 선택해야함. 스레드는 일시정지 불가
        //socket.LaunceThread();
    }
示例#22
0
        /// <summary>
        /// Cancel UDP Receive
        /// </summary>
        /// <returns></returns>
        public ActionResult CancelReceiveUDPMessage(HttpViewModel httpViewModel)
        {
            string response = "";

            HTTPManager.CancelUdpBroadcast();

            httpViewModel.HttpResponse = response;

            return(PartialView("_HttpResponse", httpViewModel));  //Note This is not used in the view we just need it because ActionResults demand a Return
        }
示例#23
0
        public void execute(System.Action <bool> eventCallback)
        {
            callback = eventCallback;

            HTTPRequest req = new HTTPRequest("POST", url);

            req.addHeader("Content-Type", "application/json");
            req.setPayload(jsonData);

            HTTPManager.sendRequest(req, HTTPCallback, retryDelayTable, deadlineDelay);
        }
示例#24
0
        public void downloadJson()
        {
            string      requestURLString = requestURL();
            HTTPRequest jsonRequest      = new HTTPRequest("POST", requestURLString);

            jsonRequest.addHeader("Content-Type", "application/json");
            string jsonInfo = jsonPayload();

            jsonRequest.setPayload(jsonInfo);
            HTTPManager.sendRequest(jsonRequest, HTTPJsonCallback, retryDelays, 20 * 60);
        }
示例#25
0
    public static bool SendGetRequest <T>(string url, Action <bool, T> callback = null) where T : NetMessage
    {
        if (!CheckMinTime(url))
        {
            Debug.LogError("Send too fast = " + url);
            return(false);
        }
        HTTPRequest req = MakeGetRequest <T>(url, callback);

        MarkCheck(url);
        return(HTTPManager.SendRequest(req) != null);
    }
示例#26
0
 internal static void SetupFolder()
 {
     try
     {
         if (string.IsNullOrEmpty(CookieFolder) || string.IsNullOrEmpty(LibraryPath))
         {
             CookieFolder = System.IO.Path.Combine(HTTPManager.GetRootCacheFolder(), "Cookies");
             LibraryPath  = System.IO.Path.Combine(CookieFolder, "Library");
         }
     }
     catch
     { }
 }
示例#27
0
        /// <summary>
        /// Send a Udp message
        /// </summary>
        /// <param name="httpViewModel"></param>
        /// <returns></returns>
        public ActionResult SendUdpBroadcast(HttpViewModel httpViewModel)
        {
            if (httpViewModel == null)
            {
                throw new ArgumentNullException(nameof(HttpViewModel));
            }

            var response = HTTPManager.SendUdpBroadcast(httpViewModel.HttpRequest, httpViewModel.HttpPortNumber);

            httpViewModel.HttpResponse = response;

            return(PartialView("_HttpResponse", httpViewModel));  //Note This is not used in the view we just need it because ActionResults demand a Return
        }
示例#28
0
        public void PostRequest(AbstractHttpProtocol proto, Callback <NetworkMsgType, string, AbstractHttpProtocol> onFinish)
        {
            this.protoBuffer = proto;
            this.onFinish    = onFinish;

            Uri         uri     = new Uri(proto.GetRequestUrl());
            HTTPRequest request = new HTTPRequest(uri, HTTPMethods.Post, true, true, OnDownloaded);

            request.ConnectTimeout           = TimeSpan.FromSeconds(connect_time_out);
            request.Timeout                  = TimeSpan.FromSeconds(time_out);
            request.RawData                  = proto.postBody;
            request.EnableTimoutForStreaming = true;
            HTTPManager.SendRequest(request);
        }
示例#29
0
        /// <summary>
        /// Creates a WebSocket instance from the given uri, protocol and origin.
        /// </summary>
        /// <param name="uri">The uri of the WebSocket server</param>
        /// <param name="origin">Servers that are not intended to process input from any web page but only for certain sites SHOULD verify the |Origin| field is an origin they expect.
        /// If the origin indicated is unacceptable to the server, then it SHOULD respond to the WebSocket handshake with a reply containing HTTP 403 Forbidden status code.</param>
        /// <param name="protocol">The application-level protocol that the client want to use(eg. "chat", "leaderboard", etc.). Can be null or empty string if not used.</param>
        /// <param name="extensions">Optional IExtensions implementations</param>
        public WebSocket(Uri uri, string origin, string protocol
#if !UNITY_WEBGL || UNITY_EDITOR
                         , params IExtension[] extensions
#endif
                         )

        {
            this.Context = new LoggingContext(this);

#if !UNITY_WEBGL || UNITY_EDITOR
            this.Extensions = extensions;

#if !BESTHTTP_DISABLE_ALTERNATE_SSL && !BESTHTTP_DISABLE_HTTP2
            if (HTTPManager.HTTP2Settings.WebSocketOverHTTP2Settings.EnableWebSocketOverHTTP2 && HTTPProtocolFactory.IsSecureProtocol(uri))
            {
                // Try to find a HTTP/2 connection that supports the connect protocol.
                var con = BestHTTP.Core.HostManager.GetHost(uri.Host).GetHostDefinition(Core.HostDefinition.GetKeyFor(new UriBuilder("https", uri.Host, uri.Port).Uri
#if !BESTHTTP_DISABLE_PROXY
                                                                                                                      , GetProxy(uri)
#endif
                                                                                                                      )).Find(c => {
                    var httpConnection = c as HTTPConnection;
                    var http2Handler   = httpConnection?.requestHandler as Connections.HTTP2.HTTP2Handler;

                    return(http2Handler != null && http2Handler.settings.RemoteSettings[Connections.HTTP2.HTTP2Settings.ENABLE_CONNECT_PROTOCOL] != 0);
                });

                if (con != null)
                {
                    HTTPManager.Logger.Information("WebSocket", "Connection with enabled Connect Protocol found!", this.Context);

                    var httpConnection = con as HTTPConnection;
                    var http2Handler   = httpConnection?.requestHandler as Connections.HTTP2.HTTP2Handler;

                    this.implementation = new OverHTTP2(this, http2Handler, uri, origin, protocol);
                }
            }
#endif

            if (this.implementation == null)
            {
                this.implementation = new OverHTTP1(this, uri, origin, protocol);
            }
#else
            this.implementation = new WebGLBrowser(this, uri, origin, protocol);
#endif

            // Under WebGL when only the WebSocket protocol is used Setup() isn't called, so we have to call it here.
            HTTPManager.Setup();
        }
示例#30
0
    // Use this for initialization
    void Start()
    {
        pageNumber = 1;

        getRanking = GetComponent<HTTPManager>();

        string rankingResult = getRanking.HTTP_REQUEST();

        if (rankingResult != "error" && rankingResult.Length != 0)
        {
            nickNames = getRanking.GetUserDataFromJson(rankingResult, "NickName");
            scores = getRanking.GetUserDataFromJson(rankingResult, "Score");

            ChangeText();
        }
    }
示例#31
0
 private static void SetupFolder()
 {
     if (string.IsNullOrEmpty(LibraryPath))
     {
         try
         {
             LibraryPath = System.IO.Path.Combine(HTTPManager.GetRootCacheFolder(), "Hosts");
             HTTPManager.IOService.FileExists(LibraryPath);
             IsSaveAndLoadSupported = true;
         }
         catch
         {
             IsSaveAndLoadSupported = false;
             HTTPManager.Logger.Warning("HostManager", "Save and load Disabled!");
         }
     }
 }
示例#32
0
    public static bool SendPostRequest <T>(string url, Dictionary <string, object> data, Action <bool, T> callback = null) where T : NetMessage
    {
        if (!CheckMinTime(url))
        {
            Debug.LogError("Send too fast = " + url);
            return(false);
        }

        HTTPRequest req = MakePostRequest <T>(url, data, callback);

        req.Timeout = new TimeSpan(0, 0, 15);
#if DEVELOPMENT_BUILD || UNITY_EDITOR
        Debug.Log("正在请求:" + url + "\n" + JsonMapper.ToJson(data));
#endif
        MarkCheck(url);
        return(HTTPManager.SendRequest(req) != null);
    }
示例#33
0
 void Start()
 {
     userData = GetComponent<HTTPManager>();
 }