1 #import "JubChatClient.h"
3 @implementation JubChatClient
4 @synthesize connection;
9 - initWithConfig: (JubConfig*)config
14 connection = [XMPPConnection new];
16 connection.username = config.username;
17 connection.domain = config.domain;
18 connection.server = config.server;
19 connection.password = config.password;
20 [connection addDelegate: self];
22 roster = [[XMPPRoster alloc] initWithConnection: connection];
23 [roster addDelegate: self];
25 streamManagement = [[XMPPStreamManagement alloc]
26 initWithConnection: connection];
28 [connection asyncConnectAndHandle];
40 [streamManagement release];
47 - (void)connection: (XMPPConnection*)connection_
48 wasBoundToJID: (XMPPJID*)jid
50 of_log(@"Bound to JID: %@", [jid fullJID]);
52 [roster requestRoster];
55 - (void)connection: (XMPPConnection*)connection_
56 didReceivePresence: (XMPPPresence*)presence_
58 if ([presence_.from isEqual: connection.JID]) {
60 didChangePresence: presence_];
61 OF_SETTER(presence, presence_, YES, 0);
65 - (void)rosterWasReceived: (XMPPRoster*)roster
67 XMPPPresence *pres = [XMPPPresence presence];
68 [pres addStatus: @"Hello from JubJub"];
69 [connection sendStanza: pres];