我希望,This is a new day! 在看代码之前,我觉得你还是应该先整理一下心情,来听我说几句: 首先,我希望你是在早上边看这篇blog,然后一边开始动手操作,如果你只是看blog而不去自己对比项目,作用不是很大。一日之计在于晨,所以怀着一颗对技术渴望,激
我希望,This is a new day!
在看代码之前,我觉得你还是应该先整理一下心情,来听我说几句:
首先,我希望你是在早上边看这篇blog,然后一边开始动手操作,如果你只是看blog而不去自己对比项目,作用不是很大。一日之计在于晨,所以怀着一颗对技术渴望,激动的,亢奋的心情去学习,你才能有所得。嗯,就拿鄙人当时做项目来说,每天早上起来的第一件事情,就是研究XMPPFramework作者的代码,按照模块来分析和模仿书写,睡觉的时候还在思考,分析,总结...
当然我并不是说每个Dev 都要向我这样,只是希望你能保持一颗积极向上的心态去对待技术,对待你的工作。
that's all。
ResourceURL:https://github.com/robbiehanson/XMPPFramework (如果你还在维护你现有的基于XMPP的产品,那么你需要sometimes 去查看,原作者是否fix 一些bug)
IphoneXMPP Demo
1.AppDelegate.m
a.大概看下头文件,ok,别跳转深入看了,下面我会教快速的看。See this method
有几个地方需要注意:
1)DDLog 用于不用不强求,鄙人喜欢干净清爽的控制台,所以就没用这玩意,因为我并不是很依赖全部打log,而是断点控制台po XXX方法,实时性找出问题修复bug
2)配置XML Stream 流 ,给你的长连接里面增加各种 buff,各种装备,各种属性。ok,不开玩笑了:),这个配置很重要,它决定了你的app需要支持哪些xmpp服务,决定了原作者(罗宾逊)哪些代码功能模块是不需要生效的
3)启动连接,当然对应的也有一个cancel connect
b 设置你的 XML Stream ,开启哪些功能
- (void)setupStream { NSAssert(xmppStream == nil, @"Method setupStream invoked multiple times"); // Setup xmpp stream // // The XMPPStream is the base class for all activity. // Everything else plugs into the xmppStream, such as modules/extensions and delegates. xmppStream = [[XMPPStream alloc] init]; #if !TARGET_IPHONE_SIMULATOR { // Want xmpp to run in the background? // // P.S. - The simulator doesn't support backgrounding yet. // When you try to set the associated property on the simulator, it simply fails. // And when you background an app on the simulator, // it just queues network traffic til the app is foregrounded again. // We are patiently waiting for a fix from Apple. // If you do enableBackgroundingOnSocket on the simulator, // you will simply see an error message from the xmpp stack when it fails to set the property. <span style="color:#66ff99;">xmppStream.enableBackgroundingOnSocket = YES;</span> } #endif // Setup reconnect // // The XMPPReconnect module monitors for "accidental disconnections" and // automatically reconnects the stream for you. // There's a bunch more information in the XMPPReconnect header file. xmppReconnect = [[XMPPReconnect alloc] init]; // Setup roster // // The XMPPRoster handles the xmpp protocol stuff related to the roster. // The storage for the roster is abstracted. // So you can use any storage mechanism you want. // You can store it all in memory, or use core data and store it on disk, or use core data with an in-memory store, // or setup your own using raw SQLite, or create your own storage mechanism. // You can do it however you like! It's your application. // But you do need to provide the roster with some storage facility. xmppRosterStorage = [[XMPPRosterCoreDataStorage alloc] init]; // xmppRosterStorage = [[XMPPRosterCoreDataStorage alloc] initWithInMemoryStore]; xmppRoster = [[XMPPRoster alloc] initWithRosterStorage:xmppRosterStorage]; xmppRoster.autoFetchRoster = YES; xmppRoster.autoAcceptKnownPresenceSubscriptionRequests = YES; // Setup vCard support // // The vCard Avatar module works in conjuction with the standard vCard Temp module to download user avatars. // The XMPPRoster will automatically integrate with XMPPvCardAvatarModule to cache roster photos in the roster. xmppvCardStorage = [XMPPvCardCoreDataStorage sharedInstance]; xmppvCardTempModule = [[XMPPvCardTempModule alloc] initWithvCardStorage:xmppvCardStorage]; xmppvCardAvatarModule = [[XMPPvCardAvatarModule alloc] initWithvCardTempModule:xmppvCardTempModule];</span> // Setup capabilities // // The XMPPCapabilities module handles all the complex hashing of the caps protocol (XEP-0115). // Basically, when other clients broadcast their presence on the network // they include information about what capabilities their client supports (audio, video, file transfer, etc). // But as you can imagine, this list starts to get pretty big. // This is where the hashing stuff comes into play. // Most people running the same version of the same client are going to have the same list of capabilities. // So the protocol defines a standardized way to hash the list of capabilities. // Clients then broadcast the tiny hash instead of the big list. // The XMPPCapabilities protocol automatically handles figuring out what these hashes mean, // and also persistently storing the hashes so lookups aren't needed in the future. // // Similarly to the roster, the storage of the module is abstracted. // You are strongly encouraged to persist caps information across sessions. // // The XMPPCapabilitiesCoreDataStorage is an ideal solution. // It can also be shared amongst multiple streams to further reduce hash lookups. xmppCapabilitiesStorage = [XMPPCapabilitiesCoreDataStorage sharedInstance]; xmppCapabilities = [[XMPPCapabilities alloc] initWithCapabilitiesStorage:xmppCapabilitiesStorage]; xmppCapabilities.autoFetchHashedCapabilities = YES; xmppCapabilities.autoFetchNonHashedCapabilities = NO; // Activate xmpp modules [xmppReconnect activate:xmppStream]; [xmppRoster activate:xmppStream]; [xmppvCardTempModule activate:xmppStream]; [xmppvCardAvatarModule activate:xmppStream]; [xmppCapabilities activate:xmppStream]; // Add ourself as a delegate to anything we may be interested in [xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()]; [xmppRoster addDelegate:self delegateQueue:dispatch_get_main_queue()]; // Optional: // // Replace me with the proper domain and port. // The example below is setup for a typical google talk account. // // If you don't supply a hostName, then it will be automatically resolved using the JID (below). // For example, if you supply a JID like 'user@quack.com/rsrc' // then the xmpp framework will follow the xmpp specification, and do a SRV lookup for quack.com. // // If you don't specify a hostPort, then the default (5222) will be used. // [xmppStream setHostName:@"talk.google.com"]; // [xmppStream setHostPort:5222]; // You may need to alter these settings depending on the server you're connecting to customCertEvaluation = YES; }
ok,let's begin.
1)创建一个XML stream 对象,这货是干嘛的呢。打个比喻:货物运输带,上货和下货 都要靠这条带子。谁让这条带子动起来?
长连接
它就是个马达。
那么这里面的货是啥呢?3种货:美版,港版,日版,偶尔带点国行。(*^__^*) 嘻嘻……,哈哈不开玩笑了。有三种货: 索达斯内!~斯ko一!~是的,好厉害好棒哒!~发现昨天看得RFC6121有点关系啦。~\(≧▽≦)/~啦啦啦 2)是否开启后台模式---NO,除非你有VOIP需要支持,不然后患无穷,现在github 上后台issue还有一大堆没解决的呢,反正呢很复杂哒,我这菜逼就没支持这货 3)开启重连机制(长连接必备,心跳啥的) 开启roster(两种形式:coreData存储 or 开辟内存--临时对象存储),自动获取服务器上的roster数据?是否自动应答 已经存在订阅出席消息的小伙伴的订阅请求,也就是说是否自动过滤掉已经订阅过的订阅或者是已经形成订阅关系的用户请求啦(难点,后面章节细讲)。开启roster CoreDataStorage,也就是数据库存CoreData储技术。 开启vCard(个人信息详情) module,二次封装vCard Module开启,并且启动 vcard对应的coreData 存储技术 开启capabilitie,和与之的存储技术。这货当初看了好久哒,但是现在真忘记了。。。sorry,这块需要找对应的XEP来进行脑补,不过貌似暂时用不到,就让它默认吧。 原文链接传送门 下面是 XMPPFramework的一个核心:multi delegate (作者独有,膜拜!~) 对roster 进行一个sub delegate回调,在当前Class,主线程队列。 关于multi delegate 技术,建议好好看看里面的具体实现,不要求你会写,大概的核心思想能看懂就成,会return BOOL YES or NO 即可。。。 btw1:鄙人对这个multi delegate再次膜拜,当然他写的很多东西,都是让我膜拜的。。比如socket链接。。。XML解析,DDLog。。。反正好多,好了不说了,说多了都是泪,菜狗只能仰望大神。。 btw2:刷刷刷两个小时过去了,洗洗睡了,写blog真心很累。 btw3:服务器那个水?问你呢,你们环境配好了没,我这边要example测试连接了,快给个账号和密码。劳资效率就是这么高,一天搞定基本的数据连接了。 btw4:经理,我这边还算顺利,约有小成,你看这连接界面,成了,虽然界面丑了点,但是能连上服务端了,真棒。 btw5:啪!你个傻蛋,别说这事demo,怎么有你这种队友。 btw6:下期预告
<span style="color:#66ff99;">xmppStream.enableBackgroundingOnSocket</span>
[xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];
[xmppRoster addDelegate:self delegateQueue:dispatch_get_main_queue()];
对XML stream 进行添加一个Sub Delegate回调,在当前Class,在mainThread Queue中,

MySQL은 GPL 라이센스를 사용합니다. 1) GPL 라이센스는 MySQL의 무료 사용, 수정 및 분포를 허용하지만 수정 된 분포는 GPL을 준수해야합니다. 2) 상업용 라이센스는 공개 수정을 피할 수 있으며 기밀이 필요한 상업용 응용 프로그램에 적합합니다.

MyISAM 대신 InnoDB를 선택할 때의 상황에는 다음이 포함됩니다. 1) 거래 지원, 2) 높은 동시성 환경, 3) 높은 데이터 일관성; 반대로, MyISAM을 선택할 때의 상황에는 다음이 포함됩니다. 1) 주로 읽기 작업, 2) 거래 지원이 필요하지 않습니다. InnoDB는 전자 상거래 플랫폼과 같은 높은 데이터 일관성 및 트랜잭션 처리가 필요한 응용 프로그램에 적합하지만 MyISAM은 블로그 시스템과 같은 읽기 집약적 및 트랜잭션이없는 애플리케이션에 적합합니다.

MySQL에서 외국 키의 기능은 테이블 간의 관계를 설정하고 데이터의 일관성과 무결성을 보장하는 것입니다. 외국 키는 참조 무결성 검사 및 계단식 작업을 통해 데이터의 효과를 유지합니다. 성능 최적화에주의를 기울이고 사용할 때 일반적인 오류를 피하십시오.

MySQL에는 B-Tree Index, Hash Index, Full-Text Index 및 공간 인덱스의 네 가지 주요 인덱스 유형이 있습니다. 1.B- 트리 색인은 범위 쿼리, 정렬 및 그룹화에 적합하며 직원 테이블의 이름 열에서 생성에 적합합니다. 2. HASH 인덱스는 동등한 쿼리에 적합하며 메모리 저장 엔진의 HASH_Table 테이블의 ID 열에서 생성에 적합합니다. 3. 전체 텍스트 색인은 기사 테이블의 내용 열에서 생성에 적합한 텍스트 검색에 사용됩니다. 4. 공간 지수는 지리 공간 쿼리에 사용되며 위치 테이블의 Geom 열에서 생성에 적합합니다.

toreateanindexinmysql, usethecreateindexstatement.1) forasinglecolumn, "createindexidx_lastnameonemployees (lastname);"2) foracompositeIndex를 사용하고 "createDexIdx_nameonemployees (forstName, FirstName);"3)을 사용하십시오

MySQL과 Sqlite의 주요 차이점은 설계 개념 및 사용 시나리오입니다. 1. MySQL은 대규모 응용 프로그램 및 엔터프라이즈 수준의 솔루션에 적합하며 고성능 및 동시성을 지원합니다. 2. SQLITE는 모바일 애플리케이션 및 데스크탑 소프트웨어에 적합하며 가볍고 내부질이 쉽습니다.

MySQL의 인덱스는 데이터 검색 속도를 높이는 데 사용되는 데이터베이스 테이블에서 하나 이상의 열의 주문 구조입니다. 1) 인덱스는 스캔 한 데이터의 양을 줄임으로써 쿼리 속도를 향상시킵니다. 2) B-Tree Index는 균형 잡힌 트리 구조를 사용하여 범위 쿼리 및 정렬에 적합합니다. 3) CreateIndex 문을 사용하여 CreateIndexIdx_customer_idonorders (customer_id)와 같은 인덱스를 작성하십시오. 4) Composite Indexes는 CreateIndexIdx_customer_orderOders (Customer_id, Order_Date)와 같은 다중 열 쿼리를 최적화 할 수 있습니다. 5) 설명을 사용하여 쿼리 계획을 분석하고 피하십시오

MySQL에서 트랜잭션을 사용하면 데이터 일관성이 보장됩니다. 1) STARTTRANSACTION을 통해 트랜잭션을 시작한 다음 SQL 작업을 실행하고 커밋 또는 롤백으로 제출하십시오. 2) SavePoint를 사용하여 부분 롤백을 허용하는 저장 지점을 설정하십시오. 3) 성능 최적화 제안에는 트랜잭션 시간 단축, 대규모 쿼리 방지 및 격리 수준을 합리적으로 사용하는 것이 포함됩니다.


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

SecList
SecLists는 최고의 보안 테스터의 동반자입니다. 보안 평가 시 자주 사용되는 다양한 유형의 목록을 한 곳에 모아 놓은 것입니다. SecLists는 보안 테스터에게 필요할 수 있는 모든 목록을 편리하게 제공하여 보안 테스트를 더욱 효율적이고 생산적으로 만드는 데 도움이 됩니다. 목록 유형에는 사용자 이름, 비밀번호, URL, 퍼징 페이로드, 민감한 데이터 패턴, 웹 셸 등이 포함됩니다. 테스터는 이 저장소를 새로운 테스트 시스템으로 간단히 가져올 수 있으며 필요한 모든 유형의 목록에 액세스할 수 있습니다.

SublimeText3 Linux 새 버전
SublimeText3 Linux 최신 버전

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

ZendStudio 13.5.1 맥
강력한 PHP 통합 개발 환경

안전한 시험 브라우저
안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.
