Exemplo n.º 1
0
        static void Main(string[] args)
        {
            string      functionResult = "";
            XayaWrapper wrapper        = new XayaWrapper(dPath, host_s, gamehostport_s, ref functionResult, CallbackFunctions.initialCallbackResult, CallbackFunctions.forwardCallbackResult, CallbackFunctions.backwardCallbackResult);

            Console.WriteLine(functionResult);
            Console.ReadLine();

            wrapper.Connect(dPath, FLAGS_xaya_rpc_url, gamehostport_s, chainType.ToString(), storageType, "mv", dPath + "\\..\\XayaStateProcessor\\database\\", dPath + "\\..\\XayaStateProcessor\\glogs\\");

            Console.WriteLine("Done");
            Console.ReadLine();
        }
Exemplo n.º 2
0
        // This BackgroundWorker thread is for launching XAYAWrapper
        private void LaunchWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            // Clean up the log files from the last session. This is from glog in libxayagame.
            string path = dataPath + "\\..\\XayaStateProcessor\\glogs\\";

            if (Directory.Exists(path))
            {
                DirectoryInfo di = new DirectoryInfo(dataPath + "\\..\\XayaStateProcessor\\glogs\\");
                foreach (FileInfo file in di.GetFiles())
                {
                    file.Delete();
                }
            }

            // Set the URL for libxayagame/XAYAWrapper RPC calls.
            FLAGS_xaya_rpc_url = ConstructRpcUrl(Properties.Settings.Default.Username, Properties.Settings.Default.Password, Properties.Settings.Default.Host, Properties.Settings.Default.Port);

            // Get a guaranteed free port.
            gameHostPort = GetAvailablePort(gameHostPort);

            // Launch the wrapper in a BackgroundWorker thread.
            string result = string.Empty;

            wrapper = new XayaWrapper(dataPath,                         // The path to the game's executable file.
                                      Properties.Settings.Default.Host, // The host, e.g. localhost or 127.0.0.1
                                      gameHostPort.ToString(),          // The game host port. Can be any free port.
                                      ref result,                       // An error or success message.
                                      CallbackFunctions.initialCallbackResult,
                                      CallbackFunctions.forwardCallbackResult,
                                      CallbackFunctions.backwardCallbackResult);

            // This is a blocking operation, so it must run in it's own thread.
            result = wrapper.Connect(dataPath,                                          // The path to the game's executable file.
                                     FLAGS_xaya_rpc_url,                                // The URL for RPC calls.
                                     gameHostPort.ToString(),                           // The game host port. Can be any free port.
                                     "0",                                               // Which network to use: Mainnet, Testnet, or Regtestnet.
                                     "memory",                                          // The storage type: memory, sqlite, or lmdb.
                                     "helloworld",                                      // The name of the game in the 'g/' namespace.
                                     dataPath + "\\..\\XayaStateProcessor\\database\\", // Path to the database folder, e.g. SQLite.
                                     dataPath + "\\..\\XayaStateProcessor\\glogs\\");   // Path to glog output folder.
        }
    IEnumerator DaemonAsync()
    {
        string functionResult = "";

        wrapper = new XayaWrapper(dPath + "\\..\\XayaStateProcessor\\", MoveGUIAndGameController.Instance.host_s, MoveGUIAndGameController.Instance.gamehostport_s, ref functionResult, CallbackFunctions.initialCallbackResult, CallbackFunctions.forwardCallbackResult, CallbackFunctions.backwardCallbackResult);

        yield return(Ninja.JumpToUnity);

        Debug.Log(functionResult);
        yield return(Ninja.JumpBack);

        functionResult = wrapper.Connect(FLAGS_xaya_rpc_url, MoveGUIAndGameController.Instance.gamehostport_s, MoveGUIAndGameController.Instance.chain_s.ToString(), MoveGUIAndGameController.Instance.GetStorageString(MoveGUIAndGameController.Instance.storage_s), "mv", dPath + "\\..\\XayaStateProcessor\\database\\", dPath + "\\..\\XayaStateProcessor\\glogs\\");

        yield return(Ninja.JumpToUnity);

        Debug.Log(functionResult);
        yield return(Ninja.JumpBack);

        Debug.Log("Check if fatal?");

        CheckIfFatalError();
    }