public NetworkResponse(string resp, string err, long index, Enumerators.GoogleNetworkType type) { recognitionType = type; netPacketIndex = index; response = resp; error = err; }
public NetworkRequest(string uri, string data, long index, Enumerators.GoogleNetworkType type) { recognitionType = type; netPacketIndex = index; if (type == Enumerators.GoogleNetworkType.GET_OPERATION) { request = new UnityWebRequest(uri, UnityWebRequest.kHttpVerbGET); } else { request = new UnityWebRequest(uri, UnityWebRequest.kHttpVerbPOST); } if (!string.IsNullOrEmpty(data)) { request.uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(data)); } request.downloadHandler = new DownloadHandlerBuffer(); request.SetRequestHeader("Content-Type", "application/json"); var config = GCSpeechRecognition.Instance.ServiceLocator.Get <ISpeechRecognitionManager>().CurrentConfig; if (config.enabledAndroidCertificateCheck) { request.SetRequestHeader("X-Android-Package", config.packageName); request.SetRequestHeader("X-Android-Cert", config.keySignature); } }
public long SendRequest(string uri, string data, Enumerators.GoogleNetworkType recognitionType) { NetworkRequest netRequest = new NetworkRequest(uri, data, _packetIndex, recognitionType); _packetIndex++; _networkRequests.Add(netRequest); netRequest.Send(); return(_packetIndex - 1); }
public NetworkRequest(string uri, string data, long index, Enumerators.GoogleNetworkType type) { recognitionType = type; netPacketIndex = index; if (type == Enumerators.GoogleNetworkType.GET_OPERATION) { request = new UnityWebRequest(uri, UnityWebRequest.kHttpVerbGET); } else { request = new UnityWebRequest(uri, UnityWebRequest.kHttpVerbPOST); } if (!string.IsNullOrEmpty(data)) { request.uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(data)); } request.downloadHandler = new DownloadHandlerBuffer(); request.SetRequestHeader("Content-Type", "application/text"); }