Esempio n. 1
0
        /// <summary>
        /// Send message to server using socket connection.
        /// </summary>
        private void SendData(string data)
        {
            if (socketConnection == null)
            {
                return;
            }

            try
            {
                var stream = socketConnection.GetStream();
                if (stream.CanWrite)
                {
                    var clientMessageAsByteArray = Encoding.ASCII.GetBytes(data);
                    stream.Write(clientMessageAsByteArray, 0, clientMessageAsByteArray.Length);
                    Debug.Log("Client sent his message - should be received by server");
                }
            }
            catch (SocketException socketException)
            {
#if UNITY_EDITOR
                Debug.LogError("Socket exception: " + socketException);
#endif
                Android.ShowAndroidToastMessage(socketException.ToString(), 20000);
            }
        }
Esempio n. 2
0
        public GuidFormatException(string message = "Cannot read access token!") : base(message)
        {
#if UNITY_EDITOR
            Debug.LogError(message);
#endif
            if (Application.platform != RuntimePlatform.Android)
            {
                return;
            }
            Android.ShowAndroidToastMessage(message, 3500);
        }
Esempio n. 3
0
        public ApiDataFormatException(string message = "Wrong QR code data format!") : base(message)
        {
#if UNITY_EDITOR
            Debug.LogError(message);
#endif
            if (Application.platform != RuntimePlatform.Android)
            {
                return;
            }
            Android.ShowAndroidToastMessage(message, 3500);
        }
Esempio n. 4
0
        public ErrorMessageException(string message = "Error type message received.") : base(message)
        {
#if UNITY_EDITOR
            Debug.LogError(message);
#endif
            if (Application.platform != RuntimePlatform.Android)
            {
                return;
            }
            Android.ShowAndroidToastMessage(message, 3500);
        }
        private IEnumerator TestInternet(string sampleUrl)
        {
            //creating request to ping
            var internet = UnityWebRequest.Get(sampleUrl);

            yield return(internet.SendWebRequest());

            //checking for connection error
            isConnected = internet.error == null;

            if (Application.platform != RuntimePlatform.Android)
            {
                yield break;
            }

            Android.ShowAndroidToastMessage(isConnected ? "Device connected" : "Device not connected(check Wi-Fi connection)");
        }