Esempio n. 1
0
        public static void RunAPICallback(SteamAPICallCompleted_t apicall)
        {
            IAPICallback apiCallback;

            if (!registeredAPICallbacks.TryGetValue(apicall.m_hAsyncCall, out apiCallback))
            {
                return;
            }

            IntPtr pData = IntPtr.Zero;

            try
            {
                bool bFailed = false;
                pData = Marshal.AllocHGlobal(apiCallback.GetExpectedSize());

                if (!Steamworks.GetAPICallResult(LastActivePipe, apicall.m_hAsyncCall, pData, apiCallback.GetExpectedSize(), apiCallback.GetExpectedCallback(), ref bFailed))
                {
                    return;
                }

                if (bFailed)
                {
                    return;
                }

                apiCallback.Run(pData);
            }
            finally
            {
                apiCallback.ClearAPICallHandle();

                Marshal.FreeHGlobal(pData);
            }
        }
Esempio n. 2
0
        private static void RunAPICallbacks(int pipe, SteamAPICallCompleted_t apicall)
        {
            IAPICallback apicallback;

            if (registeredAPICallbacks.TryGetValue(apicall.m_hAsyncCall, out apicallback))
            {
                IntPtr pData = IntPtr.Zero;

                try
                {
                    int  size    = Marshal.SizeOf(apicallback.GetType());
                    bool bFailed = false;
                    pData = Marshal.AllocHGlobal(size);

                    if (!Steamworks.GetAPICallResult(pipe, apicall.m_hAsyncCall, pData, size, apicallback.GetCallback(), ref bFailed))
                    {
                        return;
                    }

                    if (bFailed)
                    {
                        return;
                    }

                    apicallback.Run(pData);
                }
                finally
                {
                    registeredAPICallbacks.Remove(apicall.m_hAsyncCall);

                    Marshal.FreeHGlobal(pData);
                }
            }
        }
Esempio n. 3
0
        public static void RunCallbacks(int pipe)
        {
            CallbackMsg_t callbackmsg = new CallbackMsg_t();

            if (Steamworks.GetCallback(pipe, ref callbackmsg))
            {
                LastActivePipe = pipe;

                ICallback callback;
                if (registeredCallbacks.TryGetValue(callbackmsg.m_iCallback, out callback))
                {
                    callback.Run(callbackmsg.m_pubParam);
                }
                else if (unhandledCallback != null)
                {
                    unhandledCallback.Run(callbackmsg);
                }

                Steamworks.FreeLastCallback(pipe);
            }
        }
Esempio n. 4
0
        public static void RunCallbacks(int pipe)
        {
            CallbackMsg_t callbackmsg = new CallbackMsg_t();

            if (Steamworks.GetCallback(pipe, ref callbackmsg))
            {
                if (callbackmsg.m_iCallback == SteamAPICallCompleted_t.k_iCallback)
                {
                    RunAPICallbacks(pipe, ( SteamAPICallCompleted_t )Marshal.PtrToStructure(callbackmsg.m_pubParam, typeof(SteamAPICallCompleted_t)));
                }

                ICallback callback;
                if (registeredCallbacks.TryGetValue(callbackmsg.m_iCallback, out callback))
                {
                    callback.Run(callbackmsg.m_pubParam);
                }
                else if (unhandledCallback != null)
                {
                    unhandledCallback.Run(callbackmsg);
                }

                Steamworks.FreeLastCallback(pipe);
            }
        }