using System; using System.Runtime.InteropServices; using System.Threading; using AOT; namespace Sony.NP { // Token: 0x02000139 RID: 313 internal static class PopulateThread { // Token: 0x06000668 RID: 1640 [DllImport("UnityNpToolkit2")] private static extern bool PrxPopFirstResponse(out ServiceTypes service, out FunctionTypes apiCalled, out uint npRequestId, out int userId, out int customReturnCode); // Token: 0x06000669 RID: 1641 RVA: 0x000120E2 File Offset: 0x000110E2 public static void Start() { PopulateThread.stopThread = false; PopulateThread.populateThread = new Thread(new ThreadStart(PopulateThread.RunProc)); PopulateThread.populateThread.Name = "Sony Np"; PopulateThread.populateThread.Start(); } // Token: 0x0600066A RID: 1642 RVA: 0x0001211C File Offset: 0x0001111C private static void RunProc() { PopulateThread.workLoad.WaitOne(); while (!PopulateThread.stopThread) { ServiceTypes serviceTypes; FunctionTypes functionTypes; uint num; Core.UserServiceUserId userServiceUserId; int num2; if (PopulateThread.PrxPopFirstResponse(out serviceTypes, out functionTypes, out num, out userServiceUserId.id, out num2)) { RequestBase requestBase = null; NpCallbackEvent npCallbackEvent = null; try { npCallbackEvent = new NpCallbackEvent(); if (serviceTypes == ServiceTypes.Notification) { npCallbackEvent.response = Notifications.CreateNotificationResponse(functionTypes); } else { requestBase = PendingAsyncRequestList.RemoveRequest(num); npCallbackEvent.response = PendingAsyncResponseList.FindAndRemoveResponse(num); if (npCallbackEvent.response == null) { Console.WriteLine("Error : PopulateThread.RunProc : Can't find response object for Request " + num); } } if (npCallbackEvent.response != null) { npCallbackEvent.response.PopulateFromNative(num, functionTypes, requestBase); if (num2 != 0) { npCallbackEvent.response.returnCode = num2; } } npCallbackEvent.service = serviceTypes; npCallbackEvent.apiCalled = functionTypes; npCallbackEvent.npRequestId = num; npCallbackEvent.userId = userServiceUserId; npCallbackEvent.request = requestBase; Main.CallOnAsyncEvent(npCallbackEvent); } catch (NpToolkitException ex) { Console.WriteLine("Toolkit Exception - PopulateThread.RunProc : " + ex.ExtendedMessage); Console.WriteLine(ex.StackTrace); Console.WriteLine(string.Concat(new object[] { "Toolkit Exception : service = ", serviceTypes, " : apiCalled = ", functionTypes, "(", (int)functionTypes, ") : npRequestId = ", num, " : userId = ", userServiceUserId.id })); if (requestBase != null) { Console.WriteLine("Toolkit Exception - Caused by Request : " + requestBase.functionType); } if (npCallbackEvent != null && npCallbackEvent.response != null) { Console.WriteLine("Toolkit Exception - Response Type = " + npCallbackEvent.response.GetType().ToString()); } } catch (Exception ex2) { Console.WriteLine("Exception - PopulateThread.RunProc : " + ex2.Message); Console.WriteLine(ex2.StackTrace); Console.WriteLine(string.Concat(new object[] { "Toolkit Exception : service = ", serviceTypes, " : apiCalled = ", functionTypes, "(", (int)functionTypes, ") : npRequestId = ", num, " : userId = ", userServiceUserId.id })); if (requestBase != null) { Console.WriteLine("Toolkit Exception - Caused by Request : " + requestBase.functionType); } else { Console.WriteLine("Toolkit Exception - No request data available"); } } } PopulateThread.workLoad.WaitOne(); } } // Token: 0x0600066B RID: 1643 RVA: 0x00012484 File Offset: 0x00011484 public static void Execute() { PopulateThread.workLoad.Release(); } // Token: 0x0600066C RID: 1644 RVA: 0x00012492 File Offset: 0x00011492 public static void Stop() { PopulateThread.stopThread = true; PopulateThread.workLoad.Release(); } // Token: 0x0600066D RID: 1645 RVA: 0x000124A6 File Offset: 0x000114A6 [MonoPInvokeCallback(typeof(Main.OnPrxCallbackEvent))] public static void OnPrxNpToolkitEvent() { PopulateThread.Execute(); } // Token: 0x0400062F RID: 1583 private static Thread populateThread; // Token: 0x04000630 RID: 1584 private static bool stopThread = false; // Token: 0x04000631 RID: 1585 private static Semaphore workLoad = new Semaphore(0, 1000); } }