標籤:des style c class blog ext
| 編號 |
需要修改的代碼 |
| 1 |
// // Prefix header // // The contents of this file are implicitly included at the beginning of every source file. //
#import <Availability.h> //伺服器IP #define kXMPPHost @"115.29.222.253" //伺服器連接埠 #define kHostPort 5222 //伺服器名稱,也是使用者名稱尾碼 #define kHostName @"paxy.com.cn" |
| 2 |
// // // AppDelegate.m // 企信通 // // Created by chenyilong on 14-3-3. // Copyright (c) 2014年 部落格地址: http://www.cnblogs.com/ChenYilong. All rights reserved. // - (void)connect
{
// 2. 從系統偏好讀取使用者資訊
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; // NSString *hostName = [defaults stringForKey:kXMPPLoginHostNameKey];
NSString *hostName = kHostName;
NSString *userName = [defaults stringForKey:kXMPPLoginUserNameKey];
// 如果使用者名稱或者主機為空白,不再繼續 // if (hostName.length == 0 || userName.length == 0) {
if ( userName.length == 0) {
// 使用者名稱和主機都為空白說明使用者沒有登入,通常是第一次運行程式
// 直接顯示登入視窗
[self showStoryboardWithBoardName:kLoginStoryboardName];
return;
}
[_xmppStream setHostName:kXMPPHost]; [_xmppStream setHostPort:kHostPort];
_xmppStream.myJID = [XMPPJID jidWithUser:userName domain:hostName resource:nil];
// 串連
// GCDAsnycSocket架構中,所有的網路通訊都是非同步
NSError *error = nil;
if (![_xmppStream connectWithTimeout:XMPPStreamTimeoutNone error:&error]) {
DDLogInfo(@"%@", error.localizedDescription);
} else {
DDLogInfo(@"發送串連請求成功");
}
}
|
| 3 |
伺服器搭建教程:http://www.cnblogs.com/ChenYilong/p/3587344.html 基本程式介紹(使用者登入介面)教程:http://www.cnblogs.com/ChenYilong/p/3587335.html 官方demo: iPhoneXMPP.zip 54.0 KB
如需協助,[email protected]交流,朝九晚五之外(工作時間之外)才登該QQ |