< Previous by Date Date Index Next by Date >
  Thread Index  

[reSIProcate-users] presence using resiprocate


Hi,
 
I'm trying to build a simple IM with voip capabilities using resiprocate and openSER for the server. I have got registration and instant messaging working (I can IM between my client and X-Lite for instance), but I'm more or less stuck on presence. The goal is to convey simple status information (online/offline) between users in a buddylist.
 
Now, do I need to use pidf to achieve this? Or can this be achieved through the server sending notification messages (rfc3856)? If I understand it correctly, all I need for a simple online/offline status is already handled by the registration server, which will send notify messages to people who have subscribed to a sip address when some one with that address registers/unregisters.

I've been tinkering with some code and there's some chatter between my clients (or my client and X-Lite). But I don't really grasp the message flow and how it relates to the resiprocate callbacks. I've seen some example code in the mailing list, but I can't really figure out what I should be doing in each of the callbacks.
 
MyClientSubscriptionHandler *csh = new MyClientSubscriptionHandler();
MyServerSubscriptionHandler *ssh =
new MyServerSubscriptionHandler();

uaDUM->addClientSubscriptionHandler(Symbols::Presence, csh);
uaDUM->addServerSubscriptionHandler(Symbols::Presence, ssh);
 
uaDUM->getMasterProfile()->addSupportedMethod(NOTIFY);
uaDUM->getMasterProfile()->addSupportedMethod(SUBSCRIBE);
uaDUM->getMasterProfile()->validateAcceptEnabled() = false;   // not sure what does this exactly, looks safer to have it turned off while testing?
uaDUM->getMasterProfile()->validateContentEnabled() =
false;
uaDUM->getMasterProfile()->addSupportedMimeType(NOTIFY, Pidf::getStaticType());    // again, do I need this for simple online/offline status?
 
SharedPtr<SipMessage> regMessage = uaDUM->makeRegistration(uaAOR);
uaDUM->send(regMessage);
 
SharedPtr<SipMessage> SubscribeMessage = uaDUM->makeSubscription(calleeAOR, Symbols::Presence);
uaDUM->send(SubscribeMessage);
 
then my handlers:
 
// class MyServerSubscriptionHandler : public ServerSubscriptionHandler
virtual void onNewSubscription(ServerSubscriptionHandle handle, const SipMessage& sub)
{
    cout << endl <<
"MyServerSubscriptionHandler-onNewSubscription: " << sub.brief() << endl;
    SharedPtr<SipMessage> ok = handle->accept();
    handle->send(ok);
    Token state;
    state.value() = Data(
"active");
    Pidf *doc =
new Pidf(Mime("application", "pidf-xml"));
    NameAddr uaAOR = NameAddr(
"sip:peter.goeleven@xxxxxxxxxxxxxxxxxxxxxxxxxx:5070");
    doc->setEntity(uaAOR.uri());
    doc->setSimpleStatus(
true);
    ok = handle->update(doc);
    ok->header(h_SubscriptionState) = state;
    handle->send(ok);
    delete doc;
}
 
Don't know when exactly these are called or what exactly I should be doing in them:
 
virtual void onNewSubscriptionFromRefer(ServerSubscriptionHandle, const SipMessage& sub)
virtual void onRefresh(ServerSubscriptionHandle, const SipMessage& sub)   // is this one called automatically? do I need to resend anything here?
virtual void onPublished(ServerSubscriptionHandle associated, ServerPublicationHandle publication, const Contents* contents, const SecurityAttributes* attrs)
virtual void onNotifyRejected(ServerSubscriptionHandle, const SipMessage& msg)
virtual void onTerminated(ServerSubscriptionHandle) // indicates an offline status?
virtual void onReadyToSend(ServerSubscriptionHandle, SipMessage& msg)
virtual void onError(ServerSubscriptionHandle, const SipMessage& msg)
virtual void onExpiredByClient(ServerSubscriptionHandle, const SipMessage& sub, SipMessage& notify) // indicates an offline status?
virtual void onExpired(ServerSubscriptionHandle, SipMessage& notify) // indicates an offline status?
 
 
-------------------------------------
// class MyClientSubscriptionHandler : public ClientSubscriptionHandler
 
void onUpdatePending(ClientSubscriptionHandle, const SipMessage& notify, bool outOfOrder) // do I need to call acceptUpdate() here? or can this be ignored by the client and will the server always send a follow-up message?
void onUpdateActive(ClientSubscriptionHandle, const SipMessage& notify, bool outOfOrder) // some bare-bones code, I do seem to be getting the correct state here using pidf
{
    cout << endl <<
"MyClientSubscriptionHandler-onUpdateActive: " << notify.brief() << endl;
    Pidf *doc = (Pidf*) notify.getContents();
    cout << endl << doc->getSimpleStatus() << endl;

}
 
void onUpdateExtension(ClientSubscriptionHandle, const SipMessage& notify, bool outOfOrder) // when is this one called and should I be doing anything here?
int onRequestRetry(ClientSubscriptionHandle, int retrySeconds, const SipMessage& notify)
{

    return -1;
}
void onTerminated(ClientSubscriptionHandle, const SipMessage& msg)
void onNewSubscription(ClientSubscriptionHandle, const SipMessage& notify) // when is this one called and should I be doing anything here?
void onReadyToSend(ClientSubscriptionHandle, SipMessage& msg) // to allow user to add something before sending?
 
Any help is appreciated.


het ultieme online mailprogramma! Ontdek Windows Live Hotmail,