private void OnRunCallResult( #if !STDCALL IntPtr thisptr, #endif IntPtr pvParam, bool bFailed, ulong hSteamApiCall) { var hApiCall = (SteamAPICall)hSteamApiCall; if (hApiCall != _hApiCall) { return; } try { Func((T)Marshal.PtrToStructure(pvParam, typeof(T)), bFailed); } catch (Exception e) { CallbackDispatcher.ExceptionHandler(e); } // The official SDK sets _hAPICall to invalid before calling the callresult function, // this doesn't let us access .Handle from within the function though. if (hApiCall == _hApiCall) // Ensure that _hAPICall has not been changed in _Func { _hApiCall = SteamAPICall.Invalid; // Caller unregisters for us } }
public void Set(SteamAPICall hApiCall, ApiDispatchDelegate func = null) { // Unlike the official SDK we let the user assign a single function during creation, // and allow them to skip having to do so every time that they call .Set() if (func != null) { Func = func; } if (Func == null) { throw new Exception("CallResult function was null, you must either set it in the CallResult Constructor or in Set()"); } if (_hApiCall != SteamAPICall.Invalid) { NativeMethods.SteamAPI_UnregisterCallResult(_pCCallbackBase.AddrOfPinnedObject(), (ulong)_hApiCall); } _hApiCall = hApiCall; if (hApiCall != SteamAPICall.Invalid) { NativeMethods.SteamAPI_RegisterCallResult(_pCCallbackBase.AddrOfPinnedObject(), (ulong)hApiCall); } }
public void Cancel() { if (_hApiCall == SteamAPICall.Invalid) { return; } NativeMethods.SteamAPI_UnregisterCallResult(_pCCallbackBase.AddrOfPinnedObject(), (ulong)_hApiCall); _hApiCall = SteamAPICall.Invalid; }
// Shouldn't get ever get called here, but this is what C++ Steamworks does! private void OnRunCallback( #if !STDCALL IntPtr thisptr, #endif IntPtr pvParam) { _hApiCall = SteamAPICall.Invalid; // Caller unregisters for us try { Func((T)Marshal.PtrToStructure(pvParam, typeof(T)), false); } catch (Exception e) { CallbackDispatcher.ExceptionHandler(e); } }
public static bool GetAPICallResult(SteamAPICall hSteamAPICall, IntPtr pCallback, int callback, int iCallbackExpected, out bool pbFailed) { InteropHelp.TestIfAvailableClient(); return(NativeMethods.ISteamUtils_GetAPICallResult(hSteamAPICall, pCallback, callback, iCallbackExpected, out pbFailed)); }
public static ESteamApiCallFailure GetAPICallFailureReason(SteamAPICall hSteamAPICall) { InteropHelp.TestIfAvailableClient(); return(NativeMethods.ISteamUtils_GetAPICallFailureReason(hSteamAPICall)); }
/// <summary> /// <para> API asynchronous call results</para> /// <para> can be used directly, but more commonly used via the callback dispatch API (see stea_api.h)</para> /// </summary> public static bool IsAPICallCompleted(SteamAPICall hSteamAPICall, out bool pbFailed) { InteropHelp.TestIfAvailableClient(); return(NativeMethods.ISteamUtils_IsAPICallCompleted(hSteamAPICall, out pbFailed)); }
public static bool FileReadAsyncComplete(SteamAPICall hReadCall, byte[] pvBuffer, uint ToRead) { InteropHelp.TestIfAvailableClient(); return(NativeMethods.ISteamRemoteStorage_FileReadAsyncComplete(hReadCall, pvBuffer, ToRead)); }