/* * Copyright (c) 2012 Mateusz Piękos * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ #include #include #include #include #include namespace Swift { WhiteboardSession::WhiteboardSession(const JID& jid, IQRouter* router) : toJID_(jid), router_(router) { } WhiteboardSession::~WhiteboardSession() { } void WhiteboardSession::handleIncomingAction(boost::shared_ptr payload) { if (payload->getType() == WhiteboardPayload::SessionTerminate) { onSessionTerminateReceived(toJID_); return; } switch (payload->getType()) { case WhiteboardPayload::Data: onElementReceived(payload->getElement()); break; case WhiteboardPayload::SessionAccept: onRequestAccepted(toJID_); break; } } void WhiteboardSession::sendElement(const WhiteboardElement::ref element) { boost::shared_ptr payload = boost::make_shared(); payload->setElement(element); boost::shared_ptr > request = boost::make_shared >(IQ::Set, toJID_, payload, router_); request->send(); } void WhiteboardSession::cancel() { boost::shared_ptr payload = boost::make_shared(WhiteboardPayload::SessionTerminate); boost::shared_ptr > request = boost::make_shared >(IQ::Set, toJID_, payload, router_); request->send(); onSessionCancelled(toJID_); } const JID& WhiteboardSession::getTo() const { return toJID_; } }