1 #import "JubChatClient.h"
3 @implementation JubChatClient
4 @synthesize connection;
6 @synthesize contactManager;
10 - initWithConfig: (JubConfig*)config
15 connection = [XMPPConnection new];
17 connection.username = config.username;
18 connection.domain = config.domain;
19 connection.server = config.server;
20 connection.password = config.password;
21 [connection addDelegate: self];
23 roster = [[XMPPRoster alloc] initWithConnection: connection];
24 [roster addDelegate: self];
26 contactManager = [[XMPPContactManager alloc]
27 initWithConnection: connection
30 streamManagement = [[XMPPStreamManagement alloc]
31 initWithConnection: connection];
33 [connection asyncConnectAndHandle];
45 [contactManager release];
46 [streamManagement release];
53 - (void)connection: (XMPPConnection*)connection_
54 wasBoundToJID: (XMPPJID*)jid
56 of_log(@"Bound to JID: %@", [jid fullJID]);
58 [roster requestRoster];
61 - (void)connection: (XMPPConnection*)connection_
62 didReceivePresence: (XMPPPresence*)presence_
64 if ([presence_.from isEqual: connection.JID]) {
66 didChangePresence: presence_];
67 OF_SETTER(presence, presence_, YES, 0);
71 - (void)rosterWasReceived: (XMPPRoster*)roster
73 XMPPPresence *pres = [XMPPPresence presence];
74 [pres setStatus: @"Hello from JubJub"];
75 [connection sendStanza: pres];