示例#1
0
        // Sake callbacks
        public static void storageGetRecordCountCallback
        (
            IntPtr sake,
            IntPtr request,             // pointer to SAKERequest
            SAKERequestResult result,
            IntPtr inputData,
            IntPtr outputData,
            IntPtr userData
        )
        {
            respReceived = true;

            // we are keeping the record count in userData for this callback.
            // other applications might keep objects and etc.

            if (result == SAKERequestResult.SAKERequestResult_SUCCESS)
            {
                gamespySake.SAKEGetRecordCountOutput resp =
                    (gamespySake.SAKEGetRecordCountOutput)Marshal.PtrToStructure(outputData, typeof(gamespySake.SAKEGetRecordCountOutput));

                GCHandle       handle   = GCHandle.FromIntPtr(userData);
                SakeAppProgram myObject = (SakeAppProgram)handle.Target;
                myObject.recordCount = resp.mCount;
                handle.Free();

                Console.WriteLine("SUCCESS: Retrived Record Count {0}", resp.mCount);
            }
            else
            {
                Console.WriteLine("FAILURE: {0}", result);
            }
        }
示例#2
0
        public static void Main()
        {
            SakeAppProgram sakeapp = new SakeAppProgram();

            sakeapp.Run();

            AtlasAppProgram atlasapp = new AtlasAppProgram();

            atlasapp.Run();

            NatAppProgram natnegapp = new NatAppProgram();
            //natnegapp.Run();  // This requires 2 applications running simultenously.

            QR2AppProgram qr2app = new QR2AppProgram();

            qr2app.Run();

            ServerBrowserAppProgram serverBrowserApp = new ServerBrowserAppProgram();

            serverBrowserApp.Run();
        }
示例#3
0
        public static void storageGetMyRecordsCallback
        (
            IntPtr sake,
            IntPtr request,             // pointer to SAKERequest
            SAKERequestResult result,
            IntPtr inputData,
            IntPtr outputData,
            IntPtr userData
        )
        {
            respReceived = true;

            // we are keeping the record count in userData for this callback.
            // other applications might keep objects and etc.

            if (result == SAKERequestResult.SAKERequestResult_SUCCESS)
            {
                gamespySake.SAKEGetMyRecordsOutput resp =
                    (gamespySake.SAKEGetMyRecordsOutput)Marshal.PtrToStructure(outputData, typeof(gamespySake.SAKEGetMyRecordsOutput));

                //gamespySake.SAKEGetMyRecordsInput  req  =
                //  (gamespySake.SAKEGetMyRecordsInput)Marshal.PtrToStructure(inputData, typeof(gamespySake.SAKEGetMyRecordsInput));

                //User Data Reference Pointer
                GCHandle       handle   = GCHandle.FromIntPtr(userData);
                SakeAppProgram myObject = (SakeAppProgram)handle.Target;

                //Process the received Data
                IntPtr[] pRec = new IntPtr[resp.mNumRecords];
                Marshal.Copy(resp.mRecords, pRec, 0, resp.mNumRecords);

                for (int i = 0; i < resp.mNumRecords; i++)
                {
                    // Process a Record
                    Console.WriteLine("---------Record[{0}]--------- ", i);
                    for (int j = 0; j < getMyRecordsInput.mNumFields; j++)
                    {
                        // Each record is block of memory which contains the fields (Name,Value,Type)
                        gamespySake.SAKEField aSakefield = new gamespySake.SAKEField();
                        IntPtr pSakeField = new IntPtr(pRec[i].ToInt32() + j * Marshal.SizeOf(aSakefield));
                        aSakefield = (gamespySake.SAKEField)Marshal.PtrToStructure(pSakeField, typeof(gamespySake.SAKEField));;

                        switch (aSakefield.mType)
                        {
                        case SAKEFieldType.SAKEFieldType_ASCII_STRING:
                            String myAsciiString = Marshal.PtrToStringAnsi(aSakefield.mValue.mString);
                            Console.WriteLine("{0}[{1}]={2}\n", aSakefield.mName, aSakefield.mType, myAsciiString);
                            break;

                        case SAKEFieldType.SAKEFieldType_UNICODE_STRING:
                            String myUnicodeString = Marshal.PtrToStringUni(aSakefield.mValue.mString);
                            Console.WriteLine("{0}[{1}]={2}\n", aSakefield.mName, aSakefield.mType, myUnicodeString);
                            break;

                        case SAKEFieldType.SAKEFieldType_SHORT:
                            Console.WriteLine("{0}[{1}]={2}\n", aSakefield.mName, aSakefield.mType, aSakefield.mValue.mShort);
                            break;

                        case SAKEFieldType.SAKEFieldType_INT:
                            Console.WriteLine("{0}[{1}]={2}\n", aSakefield.mName, aSakefield.mType, aSakefield.mValue.mInt);
                            break;

                        case SAKEFieldType.SAKEFieldType_FLOAT:
                            Console.WriteLine("{0}[{1}]={2}\n", aSakefield.mName, aSakefield.mType, aSakefield.mValue.mFloat);
                            break;

                        case SAKEFieldType.SAKEFieldType_BYTE:
                            Console.WriteLine("{0}[{1}]={2}\n", aSakefield.mName, aSakefield.mType, aSakefield.mValue.mByte);
                            break;

                        case SAKEFieldType.SAKEFieldType_BINARY_DATA:
                            Console.Write("{0}[{1}]=", aSakefield.mName, aSakefield.mType);
                            if (aSakefield.mValue.mBinaryData.mValue != IntPtr.Zero)
                            {
                                IntPtr pBinaryData = aSakefield.mValue.mBinaryData.mValue;
                                byte[] binaryData  = new byte[aSakefield.mValue.mBinaryData.mLength];
                                Marshal.Copy(pBinaryData, binaryData, 0, binaryData.Length);
                                for (int k = 0; k < binaryData.Length; k++)
                                {
                                    Console.Write(" {0} ", binaryData[k]);
                                }
                                Console.WriteLine("\n");
                            }
                            else
                            {
                                Console.WriteLine("Null\n");
                            }
                            break;

                        case SAKEFieldType.SAKEFieldType_BOOLEAN:
                            Console.WriteLine("{0}[{1}]={2} \n", aSakefield.mName, aSakefield.mType, aSakefield.mValue.mBoolean);
                            break;

                        case SAKEFieldType.SAKEFieldType_DATE_AND_TIME:
                            Console.WriteLine("{0}[{1}]={2}\n", aSakefield.mName, aSakefield.mType, ConvertFromSeconds(aSakefield.mValue.mDateAndTime).ToString());
                            break;

                        case SAKEFieldType.SAKEFieldType_INT64:
                            Console.WriteLine("{0}[{1}]={2} \n", aSakefield.mName, aSakefield.mType, aSakefield.mValue.mInt64);
                            break;

                        default:
                            break;
                        }
                    }
                }
                Console.WriteLine("SUCCESS: Retrived {0} records\n", resp.mNumRecords);
            }
            else
            {
                Console.WriteLine("FAILURE: {0}\n", result);
            }
        }