Esempio n. 1
0
        private IEnumerator RequestLogin()
        {
            messageBoxHandler.notice("처리 중입니다.");

            WWWForm form = new WWWForm();

            form.AddField("username", userIdField.text);
            form.AddField("password", passwordField.text);

            UnityWebRequest webRequest = UnityWebRequest.Post(authServerIP + "/account/signin", form);

            yield return(webRequest.SendWebRequest());

            if (webRequest.isNetworkError || webRequest.isHttpError)
            {
                messageBoxHandler.alert("네트워크 상태가 원활하지 않습니다.");
                yield break;
            }

            messageBoxHandler.close();
            string  response     = webRequest.downloadHandler.text;
            JObject responseData = JObject.Parse(response);

            if (responseData.ContainsKey("error"))
            {
                messageBoxHandler.alert(responseData["error"].ToString());
                yield break;
            }

            AccountData.Instance.accessKey = responseData["accessKey"].ToString();
            SceneManager.LoadScene("Channel");
        }
Esempio n. 2
0
        public void connect(string ip, int port)
        {
            if (string.IsNullOrWhiteSpace(ip))
            {
                throw new Exception("IP address is null or empty");
            }

            this.ip   = ip;
            this.port = port;
            client    = new TcpClient();

            try {
                Task result = client.ConnectAsync(ip, port);
                if (!result.Wait(TimeSpan.FromSeconds(10)))
                {
                    messageBoxHandler?.alert("네트워크 상태가 원활하지 않습니다.");
                    return;
                }
            } catch (Exception error) {
                Debug.Log(error.Message);
                messageBoxHandler?.alert("서버와 연결할 수 없었습니다.", () => SceneLoader.LoadLoginScene());
                return;
            }

            stream        = client.GetStream();
            receiveWorker = new Thread(new ThreadStart(this.processReceivePacket));
            receiveWorker.Start();

            StartCoroutine(ProcessSendPacketQueue());
            StartCoroutine(ProcessReceivePacketQueue());
        }
Esempio n. 3
0
        private void searchAccountResponse(Packet rowPacket)
        {
            messageBoxHandler.close();

            var packet    = rowPacket as SearchAccountResponsePacket;
            var errorCode = (StatusCode)packet.errorCode;

            switch (errorCode)
            {
            case StatusCode.Success:
                AccountData.Instance.FamilyName          = packet.familyName;
                characterListUI.CreatableCharactersCount = packet.creatableCharactersCount;
                this.getCharacterListRequest();
                break;

            case StatusCode.Fail:
                familyNameDialog.SetActive(true);
                break;

            default:
                messageBoxHandler.alert("알 수 없는 에러 발생");
                this.searchAccountRequest();
                break;
            }
        }
Esempio n. 4
0
        public void openCreateDialog()
        {
            if (this.selectedType == CharacterClassType.None)
            {
                messageBoxHandler.alert("클래스를 선택해야 합니다.");
                return;
            }

            createDialog.SetActive(true);
        }