Commit 6cf4c29f by zhangyunjie

demo

parent 12769036
......@@ -59,8 +59,7 @@
- (void)applicationDidBecomeActive:(UIApplication *)application {
if ([OffcnIMSocketManager defaultService].IMConnectStatus != OffcnIMConnectStatusSuccess) {
//建立连接
NSString *paramStr = @"{\"server_ip\":\"192.168.43.141\", \"server_port\":1026, \"account_id\":\"ce0819db8391f1e7258a71cc9e2c3235\",\"app_id\":\"offcn_live\", \"device_type\":\"ios\", \"token\":\"fadbce3f4929b6bdee0617fee34e32ae\", \"session_id\":\"123\", \"connection_type\":\"websocket\", \"tls\":\"disable\"}";
[[OffcnIMSocketManager defaultService] connectIMServerWithParam:paramStr];
// [[OffcnIMSocketManager defaultService] connectIMServerWithAccount_id:@"ce0819db8391f1e7258a71cc9e2c3235" token:@"fadbce3f4929b6bdee0617fee34e32ae"];
}
//进入前台,清除推送角标
......
//
//
......@@ -31,11 +31,14 @@ typedef void(^OffcnIMReceiveConnectStatus)(OffcnIMConnectStatus status,NSString
@property (nonatomic, copy) OffcnIMConnectReceiveMessage connectReceiveMessage;
@property (nonatomic, copy) OffcnIMReceiveConnectStatus connectStatus;
//单例
+(OffcnIMSocketManager *)defaultService;
//建立连接
-(void)connectIMServerWithParam:(NSString *)param;
/// 建立连接
/// @param account_id 用户ID
/// @param token 用户token
-(void)connectIMServerWithAccount_id:(NSString *)account_id token:(NSString *)token;
//断开连接
-(void)disConnectIMServer;
@end
......
//
//
......@@ -10,6 +10,7 @@
#import <oimcore/oimcoreAdapter.h>
#import "ZYJMJExtension.h"
#import "DataSafe.h"
#import "SDGeneralTool.h"
@interface OffcnIMSocketManager ()<OIMCoreDelegate>
......@@ -45,6 +46,26 @@ static OffcnIMSocketManager *socketManager;
}
//建立连接
-(void)connectIMServerWithAccount_id:(NSString *)account_id token:(NSString *)token{
// connection_type = ["kcp", "websocket"]
// tls = ["disable", "enable"]
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
[dic setObjectOnSafe:@"192.168.43.141" forKey:@"server_ip"];
[dic setObjectOnSafe:[NSNumber numberWithInteger:1026] forKey:@"server_port"];
[dic setObjectOnSafe:account_id forKey:@"account_id"];
[dic setObjectOnSafe:@"offcn_live" forKey:@"app_id"];
[dic setObjectOnSafe:@"ios" forKey:@"device_type"];
[dic setObjectOnSafe:token forKey:@"token"];
NSString *session_id = [SDGeneralTool getNowSSSTimeTimestamp];
[dic setObjectOnSafe:session_id forKey:@"session_id"];
[dic setObjectOnSafe:@"websocket" forKey:@"connection_type"];
[dic setObjectOnSafe:@"disable" forKey:@"tls"];
[self connectIMServerWithParam:[dic mj_ZYJJSONString]];
}
-(void)connectIMServerWithParam:(NSString *)param{
[self.adapter ConnectImServerWithParam:param];
}
......
//
//
......@@ -22,5 +22,8 @@ typedef void(^ReturnData)(NSMutableArray *modelArr);
+ (OffcnZYJFMDBHandler *)sharedInstance;
@end
......@@ -15,6 +15,10 @@
@property (weak, nonatomic) IBOutlet UIButton *changeEnvironmentBtn;
@property (weak, nonatomic) IBOutlet UITextField *megTextField;
@property (weak, nonatomic) IBOutlet UITextField *sendIDTextField;
@property (weak, nonatomic) IBOutlet UITextField *sendTokenTextField;
@property (weak, nonatomic) IBOutlet UITextField *recvIDTextField;
@property (strong, nonatomic) NSString *fromId;
@property (strong, nonatomic) NSString *toId;
......@@ -25,6 +29,21 @@
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"demo";
self.changeEnvironmentBtn.selected = [OffcnIMSDKiOS defaultService].isTest;
self.sendIDTextField.text = @"jfdfjei0343";
self.recvIDTextField.text = @"ce0819db8391f1e7258a71cc9e2c3235";
self.sendTokenTextField.text = @"fadbce3f4929b6bdee0617fee34e32ae";
self.fromId = self.sendIDTextField.text;
self.toId = self.recvIDTextField.text;
}
#pragma mark - 切换环境
- (IBAction)clickChangeEnvironmentBtnAction:(UIButton *)sender {
sender.selected = !sender.isSelected;
......@@ -41,10 +60,7 @@
}
- (IBAction)connectAction:(UIButton *)sender {
//建立连接
// connection_type = ["kcp", "websocket"]
// tls = ["disable", "enable"]
NSString *paramStr = @"{\"server_ip\":\"192.168.43.141\", \"server_port\":1026, \"account_id\":\"ce0819db8391f1e7258a71cc9e2c3235\",\"app_id\":\"offcn_live\", \"device_type\":\"ios\", \"token\":\"fadbce3f4929b6bdee0617fee34e32ae\", \"session_id\":\"123\", \"connection_type\":\"websocket\", \"tls\":\"disable\"}";
[[OffcnIMSocketManager defaultService] connectIMServerWithParam:paramStr];
[[OffcnIMSocketManager defaultService] connectIMServerWithAccount_id:self.toId token:self.sendTokenTextField.text];
__weak typeof(self) weakSelf = self;
[OffcnIMSocketManager defaultService].connectReceiveMessage = ^(OffcnIMModel *IMModel) {
......@@ -120,6 +136,7 @@
}
msg = [msg stringByAppendingString:@"\r\n"];
msg = [msg stringByAppendingString:@"\r\n"];
}
OffcnZYJTestDataStorageView *storageView = [[OffcnZYJTestDataStorageView alloc] initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height-20)];
......@@ -158,6 +175,7 @@
}
msg = [msg stringByAppendingString:@"\r\n"];
msg = [msg stringByAppendingString:@"\r\n"];
}
OffcnZYJTestDataStorageView *storageView = [[OffcnZYJTestDataStorageView alloc] initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height-20)];
......@@ -184,6 +202,7 @@
}
msg = [msg stringByAppendingString:@"\r\n"];
msg = [msg stringByAppendingString:@"\r\n"];
}
OffcnZYJTestDataStorageView *storageView = [[OffcnZYJTestDataStorageView alloc] initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height-20)];
......@@ -236,17 +255,6 @@
}];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"demo";
self.changeEnvironmentBtn.selected = [OffcnIMSDKiOS defaultService].isTest;
self.fromId = @"jfdfjei0343";
self.toId = @"ce0819db8391f1e7258a71cc9e2c3235";
}
#pragma mark UIImagePickerControllerDelegate
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey, id> *)info {
self.pickImage = info[UIImagePickerControllerOriginalImage];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment