51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
#include "uv.h"
|
|
#include "cocos2d.h"
|
|
#include "stdarg.h"
|
|
#include "scripting/js-bindings/manual/jsb_conversions.hpp"
|
|
#include <thread>
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <list>
|
|
#include <atomic>
|
|
#include "base/ccMacros.h"
|
|
|
|
NS_CC_BEGIN
|
|
struct JSMethodParam {
|
|
std::string methodName;
|
|
std::string funId;
|
|
int paramCount;
|
|
se::ValueArray args;
|
|
};
|
|
bool addToArgArray(se::ValueArray *args, const char *valChar);
|
|
|
|
class CC_DLL JcWallet {
|
|
public:
|
|
void initEnv();
|
|
|
|
JcWallet();
|
|
|
|
virtual ~JcWallet();
|
|
|
|
static JcWallet *getInstance() { return _instance; }
|
|
|
|
char *runJsMethod(std::shared_ptr<JSMethodParam> data);
|
|
|
|
static void initJSThread(std::shared_ptr<JcWallet> wallet);
|
|
|
|
static void tick(float dt);
|
|
|
|
void performFunctionInCocosThread( const std::function<void()> &function);
|
|
|
|
void tickRun();
|
|
|
|
void jsToUnity(std::string funId, std::string msg);
|
|
|
|
private:
|
|
static JcWallet *_instance;
|
|
std::vector<std::function<void()>> _functionsToPerform;
|
|
std::mutex _performMutex;
|
|
};
|
|
|
|
NS_CC_END
|
|
|
|
bool jsb_register_walletevent_modules(se::Object* global); |