sth?
This commit is contained in:
parent
cd31627c87
commit
3181d8b0d1
@ -1,4 +1,5 @@
|
|||||||
#include "JcWallet.h"
|
#include "JcWallet.h"
|
||||||
|
#include "WalletEvent.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "cocos/scripting/js-bindings/jswrapper/SeApi.h"
|
#include "cocos/scripting/js-bindings/jswrapper/SeApi.h"
|
||||||
#include "cocos/scripting/js-bindings/manual/jsb_global.h"
|
#include "cocos/scripting/js-bindings/manual/jsb_global.h"
|
||||||
@ -6,7 +7,6 @@
|
|||||||
#include "platform/CCApplication.h"
|
#include "platform/CCApplication.h"
|
||||||
#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)
|
||||||
#import "AppDelegate.h"
|
#import "AppDelegate.h"
|
||||||
#import "WalletEvent.hpp"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||||
@ -25,11 +25,11 @@ NS_CC_BEGIN
|
|||||||
|
|
||||||
void JcWallet::initEnv() {
|
void JcWallet::initEnv() {
|
||||||
if (!_isStarted) {
|
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);
|
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);
|
g_app = cocos_android_app_init(1, 1);
|
||||||
#endif
|
#endif
|
||||||
EventDispatcher::init();
|
EventDispatcher::init();
|
||||||
g_app->start();
|
g_app->start();
|
||||||
_isStarted = true;
|
_isStarted = true;
|
||||||
@ -78,9 +78,9 @@ NS_CC_BEGIN
|
|||||||
return const_cast<char*>(result.c_str());
|
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 methodStr(methodName);
|
||||||
std::string paramsStr(params);
|
std::string paramsStr(paramObj);
|
||||||
std::string jsCode = "jc.wallet."+methodStr+"('" + paramsStr + "')";
|
std::string jsCode = "jc.wallet."+methodStr+"('" + paramsStr + "')";
|
||||||
se::Value value;
|
se::Value value;
|
||||||
jsb_run_code(jsCode, &value);
|
jsb_run_code(jsCode, &value);
|
||||||
@ -103,9 +103,10 @@ NS_CC_BEGIN
|
|||||||
char* importAccount(const char *privateKey) {
|
char* importAccount(const char *privateKey) {
|
||||||
return JcWallet::getInstance()->importAccount(privateKey);
|
return JcWallet::getInstance()->importAccount(privateKey);
|
||||||
}
|
}
|
||||||
char* runWalletMethod(const char *methodName, const char *params) {
|
char* runWalletMethod(const char *methodName, const char *paramObj) {
|
||||||
return JcWallet::getInstance()->runMethod(methodName, params);
|
return JcWallet::getInstance()->runJsMethod(methodName, paramObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
#include "cocos2d.h"
|
#include "cocos2d.h"
|
||||||
#include "base/ccMacros.h"
|
#include "base/ccMacros.h"
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
class CC_DLL JcWallet {
|
class CC_DLL JcWallet {
|
||||||
public:
|
public:
|
||||||
void initEnv();
|
void initEnv();
|
||||||
JcWallet();
|
JcWallet();
|
||||||
virtual ~JcWallet();
|
virtual ~JcWallet();
|
||||||
static JcWallet* getInstance() { return _instance; }
|
static JcWallet* getInstance() { return _instance; }
|
||||||
char* initWallet();
|
char* initWallet();
|
||||||
char* signLogin(const char *nonceChar, const char *tipChar);
|
char* signLogin(const char *nonceChar, const char *tipChar);
|
||||||
char* createAccount();
|
char* createAccount();
|
||||||
char* importAccount(const char *privateKey);
|
char* importAccount(const char *privateKey);
|
||||||
char* runMethod(const char *methodName, const char *params);
|
char* runJsMethod(const char *methodName, const char *paramObj);
|
||||||
private:
|
private:
|
||||||
static JcWallet* _instance;
|
static JcWallet* _instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// Created by zhl on 2022/7/13.
|
// Created by zhl on 2022/7/13.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "WalletEvent.hpp"
|
#include "WalletEvent.h"
|
||||||
|
|
||||||
// 定义函数指针,用来接受C#的委托
|
// 定义函数指针,用来接受C#的委托
|
||||||
void(*WalletEvent::Emit)(char* name, char* message);
|
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>"; };
|
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; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
D5F2CED9287BEC0D003C2B62 /* Il2CppMethodPointerTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Il2CppMethodPointerTable.cpp; sourceTree = "<group>"; };
|
||||||
@ -822,7 +822,7 @@
|
|||||||
D5F2CFAF287BF3BD003C2B62 /* AppDelegate.cpp */,
|
D5F2CFAF287BF3BD003C2B62 /* AppDelegate.cpp */,
|
||||||
D5F2D105287C12DD003C2B62 /* JcWallet.h */,
|
D5F2D105287C12DD003C2B62 /* JcWallet.h */,
|
||||||
D5F2D104287C12DD003C2B62 /* JcWallet.cpp */,
|
D5F2D104287C12DD003C2B62 /* JcWallet.cpp */,
|
||||||
D5538BA4287E9908000BDFB6 /* WalletEvent.hpp */,
|
D5538BA4287E9908000BDFB6 /* WalletEvent.h */,
|
||||||
D5538BA3287E9908000BDFB6 /* WalletEvent.cpp */,
|
D5538BA3287E9908000BDFB6 /* WalletEvent.cpp */,
|
||||||
);
|
);
|
||||||
path = Classes_cocos;
|
path = Classes_cocos;
|
||||||
|
Binary file not shown.
@ -20,38 +20,6 @@
|
|||||||
landmarkType = "7">
|
landmarkType = "7">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
</BreakpointProxy>
|
</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
|
<BreakpointProxy
|
||||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
<BreakpointContent
|
<BreakpointContent
|
||||||
|
Loading…
x
Reference in New Issue
Block a user