internal static global::System.Runtime.InteropServices.HandleRef getCPtr(BondHelper obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public async Task <PlayFabResult <WriteEventsResponse> > WriteTelemetryEventsAsync(WriteEventsRequest request, object customData = null, Dictionary <string, string> extraHeaders = null) #endif { if (request.Events.Count == 0) { var apiMethodResult = new PlayFabResult <WriteEventsResponse> { Error = new OneDsError { Error = PlayFabErrorCode.ContentNotFound, ErrorMessage = "No events found in request. Please make sure to provide at least one event in the batch.", HttpStatus = "OneDSError" }, CustomData = customData }; #if TPL_35 return(Task.Run(() => apiMethodResult)); #else return(apiMethodResult); #endif } if (!this.IsOneDSAuthenticated) { var apiMethodResult = new PlayFabResult <WriteEventsResponse> { Error = new OneDsError { Error = PlayFabErrorCode.AuthTokenDoesNotExist, ErrorMessage = "OneDS API client is not authenticated. Please make sure OneDS credentials are set.", HttpStatus = "OneDSError" }, CustomData = customData }; #if TPL_35 return(Task.Run(() => apiMethodResult)); #else return(apiMethodResult); #endif } // get transport plugin for OneDS var transport = PluginManager.GetPlugin <IOneDSTransportPlugin>(PluginContract.PlayFab_Transport, PluginManager.PLUGIN_TRANSPORT_ONEDS); // compose batch using One Collector's Common Schema 3.0 byte[] serializedBatch; using (var ms = new MemoryStream()) { foreach (var eventContents in request.Events) { var csEvent = new OneDSCsEvent(); csEvent.data = new List <OneDSEventData>(); var data = eventContents.Payload as OneDSEventData; if (data != null) { csEvent.data.Add(data); } csEvent.name = eventContents.Name; csEvent.iKey = this.oneDSProjectIdIkey; csEvent.time = DateTime.UtcNow.Ticks; csEvent.ver = "3.0"; csEvent.baseType = string.Empty; csEvent.flags = 1; // serialize CS 3.0 event using bond BondHelper.Serialize(csEvent, ms); } #if !UNITY_WSA && !UNITY_WP8 && !UNITY_WEBGL ms.Position = 0; byte[] packageBytes = ms.ToArray(); ms.SetLength(0); // Gzip content using (var gZipStream = new GZipStream(ms, CompressionMode.Compress, true)) { gZipStream.Write(packageBytes, 0, packageBytes.Length); } #endif serializedBatch = ms.ToArray(); } // send serialized binary content of batch var headers = new Dictionary <string, string>(); headers["APIKey"] = this.oneDSIngestionKey; headers["Tickets"] = "\"" + oneDSHeaderJwtTicketKey + "\": \"" + oneDSHeaderJwtTicketPrefix + ":" + oneDSJwtToken + "\""; if (extraHeaders != null) { foreach (var extraHeader in extraHeaders) { headers.Add(extraHeader.Key, extraHeader.Value); } } PlayFabResult <WriteEventsResponse> result = null; transport.DoPost(serializedBatch, headers, httpResult => { if (httpResult is OneDsError) { var error = (OneDsError)httpResult; result = new PlayFabResult <WriteEventsResponse> { Error = error, CustomData = customData }; return; } result = new PlayFabResult <WriteEventsResponse> { Result = new WriteEventsResponse(), CustomData = customData }; }); #if TPL_35 return(Task.Run(() => { OneDsUtility.WaitWhile(() => result == null).Await(); return result; })); #else await OneDsUtility.WaitWhile(() => result == null); return(result); #endif }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(BondHelper obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; }