XMMP.Framework
BXXMPPConn Class
BXXMPPConn class delivers XMPP connection to the server. It handles server unraveling (basing on SRV records of domains DNS) and connection. Giving you easy-to-use interface. You don't need to think about connection encryption or authorisation. Everything is done without your notice. Class will choose the best encryption and authorisation method possible. It also gives you possiblity to be notified about the events that are comming from server. You can register yourself for all of them at once; or for only few of them. The less you will be registered for, the more the library will do for you. But let's go on with it.
BXXMPPConn delivers following methods:
Constructors
-(id)init;
Standard class constructor. It does not set any values into it. You have to do it via setters, before you will try to make the connection.
-(id)initWithJID:(BXJID? *)JID;
Minimalistic class construtor that gives us a class ready to connect. The password is still not set, but BXXMPPConn will ask for the password
via callback when it will be ready to use it. If right delegate will be registered.
-(id)initWithJID:(BXJID? *)JID andPassword:(NSString *)passwd;
Class constructor. The given JID will be used as users JID. Password will be used to register to the server.
Setters & getters
-(BOOL)setJID:(BXJID? *)JID;
Setting new JID. Value can be changed ONLY if connection is not established yet. Returns YES if change was successful, NO otherwise.
-(BOOL)setPassword:(NSString *)newPasswd;
Setting new password. Value can be changed ONLY if connection is not established yet and JID is already set. Returns YES if change was successful, NO otherwise.
-(BOOL)setDomain:(NSString *)theDomain andPort:(int)thePort;
In some cases, server could be different from the domain. And given port could also be different then the standard 5222. In most of the cases everything is covered with appropriate SRV records in domains DNS. But not always. That is why we are giving you this method to set those things up on your own. Method can be used ONLY if connection is not established yet and JID with password is already set. Returns YES if change was successful, NO otherwise.
-(void)setDelegate:(id)newGlobalDelegate;
This setter sets a global delegate to retrieve ALL events from the connection. It will override all other delegate settings and is not recommended. Better is to register only delegates to actions you would really want to listen to. For list of all callbacks you would need to implement look to the callbacks section below.
-(void)setSessionDelegate:(id)newSessionDelegate;
Register delegate to listen to session events like session establishement, authorisation or errors. Delegate needs to implement sessionEvent method listed below in callbacks section.
-(void)setXMLDelegate:(id)newXMLDelegate;
Register delegate to listen to XML nodes sent to and recieved from the connection. Delegate has to implement to methods: nodeSent and nodeRecieved listed below in callbacks section.
-(void)setPresenceDelegate:(id)newPresenceDelegate;
Register delegate to listen to presence changes send from server. Delegate needs to implement presenceEvent from method listed bellow in callbacks section.
-(void)setMessageDelegate:(id)newMessageDelegate;
Register delegate to listen to messages sent from the server. Delegate needs to implement newMessage from method listed bellow in callbacks section.
-(void)setQueryDelegate:(id)newQueryDelegate;
Register delegate to listen to query events sent from the server. Delegate needs to implement QueryEvent from method listed bellow in callbacks section. Warning: Overriding this delegate will deativate functionality of sending queries via sendQuery method.
-(id)sessionDelegate;
Returns session delegate object.
-(id)XMLDelegate;
Returns XML delegate object.
-(id)presenceDelegate;
Returns presence delegate object.
-(id)messageDelegate;
Returns message delegate object.
-(id)queryDelegate;
Returns query delegate object.
-(BXJID? *)getJID;
Returns JID set for the connection.
-(BOOL)isConnected;
Returns if current class is currently connected to the server.
Actions
-(void)makeConnection;
Method to perform the connection to the server. Remember to register all your delegates first. Because about the status of the connection and events that will come from it, you will be informed only via callbacks sent to those.
-(void)closeConnection;
Method sends farewell to the server and closes TCP connection with it. Notification about closure are sent to delegate via sessionEvent callback.
-(void)setState:(BXPresenceState?)theState;
Sets presence state of the user. Default (5) OR previously set prio is used. Empty OR previously set Status is used.
-(void)setState:(BXPresenceState?)theState withPrio:(int)thePrio;
Sets presence state of the user with given prio. Empty OR previously set Status is used.
-(void)setState:(BXPresenceState?)theState withStatus:(NSString *)theStatus;
Sets presence state of the user with given status message. Default (5) OR previously set prio is used.
-(void)setState:(BXPresenceState?)theState withStatus:(NSString *)theStatus andPrio:(int)thePrio;
Sets presence state of the user with given status message and prio.
-(void)sendMessage:(BXMessage? *)msg to:(BXJID? *)JID;
Sends given message to person described by jid.
-(void)sendQuery:(BXXMLNode? *)query andNotify:(id *)obj;
Sends query to server. When server will answer given object will be notified about the result through gotAnswer callback method that it should implement.
