sth?
This commit is contained in:
parent
cd31627c87
commit
3181d8b0d1
@ -1,4 +1,5 @@
|
||||
#include "JcWallet.h"
|
||||
#include "WalletEvent.h"
|
||||
#include <string>
|
||||
#include "cocos/scripting/js-bindings/jswrapper/SeApi.h"
|
||||
#include "cocos/scripting/js-bindings/manual/jsb_global.h"
|
||||
@ -6,7 +7,6 @@
|
||||
#include "platform/CCApplication.h"
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
#import "AppDelegate.h"
|
||||
#import "WalletEvent.hpp"
|
||||
#endif
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
@ -25,11 +25,11 @@ NS_CC_BEGIN
|
||||
|
||||
void JcWallet::initEnv() {
|
||||
if (!_isStarted) {
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
g_app = new AppDelegate(1, 1);
|
||||
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
g_app = cocos_android_app_init(1, 1);
|
||||
#endif
|
||||
#endif
|
||||
EventDispatcher::init();
|
||||
g_app->start();
|
||||
_isStarted = true;
|
||||
@ -78,9 +78,9 @@ NS_CC_BEGIN
|
||||
return const_cast<char*>(result.c_str());
|
||||
}
|
||||
|
||||
char* runMethod(const char *methodName, const char *params) {
|
||||
char* JcWallet::runJsMethod(const char *methodName, const char *paramObj) {
|
||||
std::string methodStr(methodName);
|
||||
std::string paramsStr(params);
|
||||
std::string paramsStr(paramObj);
|
||||
std::string jsCode = "jc.wallet."+methodStr+"('" + paramsStr + "')";
|
||||
se::Value value;
|
||||
jsb_run_code(jsCode, &value);
|
||||
@ -103,9 +103,10 @@ NS_CC_BEGIN
|
||||
char* importAccount(const char *privateKey) {
|
||||
return JcWallet::getInstance()->importAccount(privateKey);
|
||||
}
|
||||
char* runWalletMethod(const char *methodName, const char *params) {
|
||||
return JcWallet::getInstance()->runMethod(methodName, params);
|
||||
char* runWalletMethod(const char *methodName, const char *paramObj) {
|
||||
return JcWallet::getInstance()->runJsMethod(methodName, paramObj);
|
||||
}
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
@ -1,19 +1,20 @@
|
||||
#include "cocos2d.h"
|
||||
#include "base/ccMacros.h"
|
||||
NS_CC_BEGIN
|
||||
class CC_DLL JcWallet {
|
||||
public:
|
||||
void initEnv();
|
||||
JcWallet();
|
||||
virtual ~JcWallet();
|
||||
static JcWallet* getInstance() { return _instance; }
|
||||
char* initWallet();
|
||||
char* signLogin(const char *nonceChar, const char *tipChar);
|
||||
char* createAccount();
|
||||
char* importAccount(const char *privateKey);
|
||||
char* runMethod(const char *methodName, const char *params);
|
||||
private:
|
||||
static JcWallet* _instance;
|
||||
};
|
||||
class CC_DLL JcWallet {
|
||||
public:
|
||||
void initEnv();
|
||||
JcWallet();
|
||||
virtual ~JcWallet();
|
||||
static JcWallet* getInstance() { return _instance; }
|
||||
char* initWallet();
|
||||
char* signLogin(const char *nonceChar, const char *tipChar);
|
||||
char* createAccount();
|
||||
char* importAccount(const char *privateKey);
|
||||
char* runJsMethod(const char *methodName, const char *paramObj);
|
||||
private:
|
||||
static JcWallet* _instance;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
// Created by zhl on 2022/7/13.
|
||||
//
|
||||
|
||||
#include "WalletEvent.hpp"
|
||||
#include "WalletEvent.h"
|
||||
|
||||
// 定义函数指针,用来接受C#的委托
|
||||
void(*WalletEvent::Emit)(char* name, char* message);
|
||||
|
23
Classes_cocos/WalletEvent.h
Normal file
23
Classes_cocos/WalletEvent.h
Normal file
@ -0,0 +1,23 @@
|
||||
//
|
||||
// WalletEvent.h
|
||||
// Unity-iPhone
|
||||
//
|
||||
// Created by zhl on 2022/7/13.
|
||||
//
|
||||
|
||||
|
||||
#pragma once
|
||||
extern "C"
|
||||
{
|
||||
class WalletEvent
|
||||
{
|
||||
public:
|
||||
static void (*Emit)(char* name, char* message);
|
||||
};
|
||||
|
||||
// 注册C#的委托
|
||||
void registWalletEventDelegate(void (*Emit)(char* name, char* message));
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,30 +0,0 @@
|
||||
//
|
||||
// WalletEvent.hpp
|
||||
// Unity-iPhone
|
||||
//
|
||||
// Created by zhl on 2022/7/13.
|
||||
//
|
||||
|
||||
#ifndef WalletEvent_hpp
|
||||
#define WalletEvent_hpp
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#pragma once
|
||||
#include<string.h>
|
||||
#include<iostream>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
class WalletEvent
|
||||
{
|
||||
public:
|
||||
static void (*Emit)(char* name, char* message);
|
||||
};
|
||||
|
||||
// 注册C#的委托
|
||||
void registWalletEventDelegate(void (*Emit)(char* name, char* message));
|
||||
|
||||
}
|
||||
|
||||
#endif /* WalletEvent_hpp */
|
@ -347,7 +347,7 @@
|
||||
AAFE69D119F187C200638316 /* UnityViewControllerListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UnityViewControllerListener.mm; sourceTree = "<group>"; };
|
||||
C6CC4EECB3BBA57C6F9A8015 /* IUnityInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = IUnityInterface.h; path = Classes/Unity/IUnityInterface.h; sourceTree = SOURCE_ROOT; };
|
||||
D5538BA3287E9908000BDFB6 /* WalletEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WalletEvent.cpp; sourceTree = "<group>"; };
|
||||
D5538BA4287E9908000BDFB6 /* WalletEvent.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = WalletEvent.hpp; sourceTree = "<group>"; };
|
||||
D5538BA4287E9908000BDFB6 /* WalletEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WalletEvent.h; sourceTree = "<group>"; };
|
||||
D5F2CED5287BE9C4003C2B62 /* Data */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Data; path = ../tebg/Data; sourceTree = "<group>"; };
|
||||
D5F2CED8287BEC0D003C2B62 /* Bulk_Generics_3.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Bulk_Generics_3.cpp; sourceTree = "<group>"; };
|
||||
D5F2CED9287BEC0D003C2B62 /* Il2CppMethodPointerTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Il2CppMethodPointerTable.cpp; sourceTree = "<group>"; };
|
||||
@ -822,7 +822,7 @@
|
||||
D5F2CFAF287BF3BD003C2B62 /* AppDelegate.cpp */,
|
||||
D5F2D105287C12DD003C2B62 /* JcWallet.h */,
|
||||
D5F2D104287C12DD003C2B62 /* JcWallet.cpp */,
|
||||
D5538BA4287E9908000BDFB6 /* WalletEvent.hpp */,
|
||||
D5538BA4287E9908000BDFB6 /* WalletEvent.h */,
|
||||
D5538BA3287E9908000BDFB6 /* WalletEvent.cpp */,
|
||||
);
|
||||
path = Classes_cocos;
|
||||
|
Binary file not shown.
@ -20,38 +20,6 @@
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "66F009A1-1D09-4BA5-B87D-9D3A78A3E7A7"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Classes_cocos/JcWallet.cpp"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "56"
|
||||
endingLineNumber = "56"
|
||||
landmarkName = "JcWallet::signLogin(nonceChar, tipChar)"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "69985091-CD68-4724-A88A-A28EAE90C0CB"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Classes_cocos/JcWallet.cpp"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "66"
|
||||
endingLineNumber = "66"
|
||||
landmarkName = "JcWallet::createAccount()"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
|
Loading…
x
Reference in New Issue
Block a user