uc sdk monotouch应用
近来又开始对接UC的SDK对他应用到monodevelop平台上面的时候也是会有一些问题。这里面是写的源代码。我们先看一下生成.a的工程文件//
// UseStaticLibraryUc.h
// UseStaticLibraryUc
//
// Created by huangyushi on 13-1-22.
// Copyright (c) 2013年 huangyushi. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <pthread.h>
#import "UCGameSdk.h"
#import "UCGameSdkConst.h"
#import "StaticLibraryManager.h"
typedef NSString* (^charge_cb) (NSInteger nType);
typedef struct{
int _roleid;
NSString* _rolename;
NSString* _customInfo;
}product_t;
@inte易做图ce UseStaticLibraryUc : UIViewController<UCGameSdkProtocol>
//加载
- (void)viewDidLoad;
- (void)viewDidUnload;
//登陆部分
- (void)onSdkInitFin: (NSNotification *) notification;
- (void)onLoginFin: (NSNotification *) notification;
- (void)onUnloginExit;
//支付部分
- (void)onPayFin: (NSNotification *) notification;
- (void)payExit: (NSNotification *) notification;
- (void)buy:(NSInteger )roleId RoleName:(NSString* )roleName customInfo:(NSString* )customInfo;
//封装对外接口
+(UseStaticLibraryUc* )Isrance;
-(void)setInitComplete:(charge_cb)complete;
-(void)loginUC:(charge_cb)suc Fail:(charge_cb)fail Cancel:(charge_cb)cancel;
-(void)buyUC:(NSInteger )_roleId RoleName:(NSString* )_roleName customInfo:(NSString* )_customInfo Success:(charge_cb)suc Fail:(charge_cb)fail Cancel:(charge_cb)cancel;
-(void)setConnectFunc:(charge_cb)sd Rec:(charge_cb)rec Packet:(charge_cb)packet;
-(NSString* )getUserName;
-(NSString* )getUserPasswd;
-(NSString* )getSid;
@end
//
// UseStaticLibraryUc.m
// UseStaticLibraryUc
//
// Created by huangyushi on 13-1-22.
// Copyright (c) 2013年 huangyushi. All rights reserved.
//
#import "UseStaticLibraryUc.h"
static charge_cb call_backs[10] = {NULL};
static NSString* game_user =NULL;
static NSString* game_passwd =NULL;
//游戏帐号登录需要用到的变量
static pthread_cond_t thread_cond =PTHREAD_COND_INITIALIZER;
static pthread_mutex_t thread_lock =PTHREAD_MUTEX_INITIALIZER;
static pthread_t connect_to_our_server =0;
static NSString* ucsid =NULL;
static NSMutableDictionary *resultDict;
void* wait_for_cour_server_replay(void* arg)
{
ucsid = NULL;
while (true)
{
if (call_backs[connect_packet] !=NULL) {
call_backs[connect_packet](connect_packet);
}
if (call_backs[Connect_receive] !=NULL) {
if (call_backs[Connect_receive](Connect_receive) !=NULL) {
ucsid = [NSStringstringWithFormat:@"%@",call_backs[Connect_receive](Connect_receive)];
if (ucsid ==@"error") {
[resultDictsetValue:[NSNumber numberWithInt:1]forKey:@"resultCode"];
[resultDict setValue:@"帐号或密码错误,请重新输入." forKey:@"resultMsg"];
pthread_cond_signal(&thread_cond);//唤醒阻塞的线程
break;
}
}
}
if(NULL != ucsid){
int resultCode = 0;
[resultDict setValue:ucsid forKey:@"sid"];
[resultDict setValue: [NSNumbernumberWithInt : resultCode] forKey:@"resultCode"];
[resultDict setValue:@"OK"forKey:@"resultMsg"];
pthread_cond_signal(&thread_cond);//唤醒阻塞的线程
break;
}
}
return NULL;
}
@implementation UseStaticLibraryUc
- (void)viewDidUnload{
}
-(void)viewDidLoad
{
}
//登陆部分
-(id)init
{
self = [super init];
if(NULL != self)
{
[[NSNotificationCenterdefaultCenter] removeObserver:self];
//添加 Observer来监听 SDK 初始化事件,以便在 SDK初始化完成时进行后续处理。
[[NSNotificationCenterdefaultCenter] addObserver:self
selector:@selector(onSdkInitFin:)
name:UCG_SDK_MSG_SDK_INIT_FIN
object:nil];
//设置游戏相关参数
UCGameSdk *sdk = [UCGameSdkdefaultSDK];
/** 设置游戏相关参数*/
//正式
// sdk.cpId = 593; // 设置游戏合作商编号,该编号在游戏接入时由 UC 分配
// sdk.gameId = 105539; // 设置游戏编号,该编号在游戏接入时由 UC 分配
// sdk.serverId= 1245; // 设置游戏服务器 ID,该编号由所在的游戏分区决定
//测试
sdk.cpId =1; // 设置游戏合作商编号,该编号在游戏接
补充:移动开发 , IOS ,
上一个:ios开发中网络和设备名称判断
下一个:IOS的一些小知识
- 更多wap疑问解答:
- 新人求助QPainter
- 为什么程序都退出了还可以收到推送?如果大多设备都可以推送那运营商怎么办?
- qt 4.7 sqlserver2000 存储过程调用
- 关于ANDROID4.0.1编译问题!
- Android FrameBuffer读屏幕30秒后mmap失败
- 联通粗定位用java程序如何来请求和接受数据
- 为什么QT运行Android平台的程序时,mouseMoveEvent事件响应的间隔时间很长??????????
- android与PC蓝牙通讯
- 指定大小的label 内容可变,如果内容超出label的宽度,将未能显示的部分显示在另一个label上
- Android调试
- android如何通过wifi连接无线打印机
- 运行程序,release目录下产生一个乱码文件夹
- 分享个某机构最新安卓资料,自己验证了
- service启动不起来,掉不了service connection
- 求助:QT5.0 没有QPrinter吗