Ejemplo n.º 1
0
        public XayaWrapper(string dataPath, string host_s, string gamehostport_s, ref string result, InitialCallback inCal, ForwardCallback forCal, BackwardCallback backCal)
        {
            if (!NativeMethods.SetDllDirectory(dataPath + "\\..\\XayaStateProcessor\\"))
            {
                result = "Could not set dll directory";
                return;
            }

            string path = dataPath.Replace("/", "\\") + "\\..\\XayaStateProcessor\\libxayawrap.dll";

            pDll = NativeMethods.LoadLibrary(dataPath.Replace("/", "\\") + "\\..\\XayaStateProcessor\\libxayawrap.dll");
            //Console.WriteLine("error: " + Marshal.GetLastWin32Error());

            if (pDll == IntPtr.Zero)
            {
                result = "Could not load " + dataPath.Replace("/", "\\") + "\\..\\XayaStateProcessor\\libxayawrap.dll";
                return;
            }

            IntPtr pSetInitialCallback = NativeMethods.GetProcAddress(pDll, "setInitialCallback");

            if (pSetInitialCallback == IntPtr.Zero)
            {
                result = "Could not load resolve setInitialCallback";
                return;
            }

            IntPtr pSetForwardCallback = NativeMethods.GetProcAddress(pDll, "setForwardCallback");

            if (pSetForwardCallback == IntPtr.Zero)
            {
                result = "Could not load resolve pSetForwardCallback";
                return;
            }

            IntPtr pSetBackwardCallback = NativeMethods.GetProcAddress(pDll, "setBackwardCallback");

            if (pSetBackwardCallback == IntPtr.Zero)
            {
                result = "Could not load resolve pSetBackwardCallback";
                return;
            }

            setInitialCallback  SetInitialCallback  = (setInitialCallback)Marshal.GetDelegateForFunctionPointer(pSetInitialCallback, typeof(setInitialCallback));
            setForwardCallback  SetForwardlCallback = (setForwardCallback)Marshal.GetDelegateForFunctionPointer(pSetForwardCallback, typeof(setForwardCallback));
            setBackwardCallback SetBackwardCallback = (setBackwardCallback)Marshal.GetDelegateForFunctionPointer(pSetBackwardCallback, typeof(setBackwardCallback));

            initialCallback = new InitialCallback(inCal);
            SetInitialCallback(initialCallback);

            forwardCallback = new ForwardCallback(forCal);
            SetForwardlCallback(forwardCallback);

            backwardsCallback = new BackwardCallback(backCal);
            SetBackwardCallback(backwardsCallback);

            xayaGameService = new XAYAService(host_s + ":" + gamehostport_s, "", "", "");
            IsConnected     = true;
            result          = "Wrapper Initialised";
        }
        public XayaWrapper(string dllDirectoryPath, string host_s, string gamehostport_s, ref string result, InitialCallback inCal, ForwardCallback forCal, BackwardCallback backCal)
        {
            if (!NativeMethods.SetDllDirectory(dllDirectoryPath))
            {
                result = "Could not set dll directory";
                return;
            }

            pDll = NativeMethods.LoadLibrary(dllDirectoryPath + "libxayawrap.dll");


            if (pDll == IntPtr.Zero)
            {
                result = "Could not load " + dllDirectoryPath + "libxayawrap.dll";
                return;
            }

            IntPtr pSetInitialCallback = NativeMethods.GetProcAddress(pDll, "setInitialCallback");

            if (pSetInitialCallback == IntPtr.Zero)
            {
                result = "Could not load resolve setInitialCallback";
                return;
            }

            IntPtr pSetForwardCallback = NativeMethods.GetProcAddress(pDll, "setForwardCallback");

            if (pSetForwardCallback == IntPtr.Zero)
            {
                result = "Could not load resolve pSetForwardCallback";
                return;
            }

            IntPtr pSetBackwardCallback = NativeMethods.GetProcAddress(pDll, "setBackwardCallback");

            if (pSetBackwardCallback == IntPtr.Zero)
            {
                result = "Could not load resolve pSetBackwardCallback";
                return;
            }

            setInitialCallback  SetInitialCallback  = (setInitialCallback)Marshal.GetDelegateForFunctionPointer(pSetInitialCallback, typeof(setInitialCallback));
            setForwardCallback  SetForwardlCallback = (setForwardCallback)Marshal.GetDelegateForFunctionPointer(pSetForwardCallback, typeof(setForwardCallback));
            setBackwardCallback SetBackwardCallback = (setBackwardCallback)Marshal.GetDelegateForFunctionPointer(pSetBackwardCallback, typeof(setBackwardCallback));

            initialCallback = new InitialCallback(inCal);
            SetInitialCallback(initialCallback);

            forwardCallback = new ForwardCallback(forCal);
            SetForwardlCallback(forwardCallback);

            backwardsCallback = new BackwardCallback(backCal);
            SetBackwardCallback(backwardsCallback);

            xayaGameService = new XAYAService(host_s + ":" + gamehostport_s, "", "", "");


            result = "Wrapper Initialised";
        }
Ejemplo n.º 3
0
    public bool Connect()
    {
        xayaService = new XAYAService(MoveGUIAndGameController.Instance.host_s + ":" + MoveGUIAndGameController.Instance.hostport_s + "/wallet/game.dat", MoveGUIAndGameController.Instance.rpcuser_s, MoveGUIAndGameController.Instance.rpcpassword_s, "", 10);

        if (xayaService.GetConnectionCount() > 0)
        {
            // We are not tracking connection drops or anything
            // here for the same of simplicity.We just assume
            // that once we are connected, then we are always fine.

            connector.SubscribeForBlockUpdates();

            connected = true;
            return(true);
        }
        else
        {
            Debug.LogError("Failed to connect with XAYAService.");
        }
        return(false);
    }
Ejemplo n.º 4
0
    public bool Connect()
    {
        xayaService = new XAYAService("http://" + GlobalData.gSettingInfo.xayaURL, GlobalData.gSettingInfo.rpcUserName, GlobalData.gSettingInfo.rpcUserPassword, "", 10);

        if (xayaService.GetConnectionCount() > 0)
        {
            // We are not tracking connection drops or anything
            // here for the same of simplicity.We just assume
            // that once we are connected, then we are always fine.

            //connector.SubscribeForBlockUpdates();


            connected = true;
            return(true);
        }
        else
        {
            Debug.Log("Failed to connect with XAYAService.");
        }
        return(false);
    }