summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Piekos <mateuszpiekos@gmail.com>2012-07-30 07:11:18 (GMT)
committerMateusz Piekos <mateuszpiekos@gmail.com>2012-07-30 07:11:18 (GMT)
commit5fafa602d859657d6616acdbb63dfcd501aed9a0 (patch)
tree1d74dc4871b888ab298c756598c3ad9a422588a5 /Swiften
parent944b240a9f72f967f3fd2a840e4efbd2f0ef4183 (diff)
downloadswift-contrib-5fafa602d859657d6616acdbb63dfcd501aed9a0.zip
swift-contrib-5fafa602d859657d6616acdbb63dfcd501aed9a0.tar.bz2
Exchanged client and server roles in whiteboard session classes
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Whiteboard/IncomingWhiteboardSession.cpp56
-rw-r--r--Swiften/Whiteboard/IncomingWhiteboardSession.h4
-rw-r--r--Swiften/Whiteboard/OutgoingWhiteboardSession.cpp59
-rw-r--r--Swiften/Whiteboard/OutgoingWhiteboardSession.h4
4 files changed, 25 insertions, 98 deletions
diff --git a/Swiften/Whiteboard/IncomingWhiteboardSession.cpp b/Swiften/Whiteboard/IncomingWhiteboardSession.cpp
index 39eb435..1904457 100644
--- a/Swiften/Whiteboard/IncomingWhiteboardSession.cpp
+++ b/Swiften/Whiteboard/IncomingWhiteboardSession.cpp
@@ -29,57 +29,25 @@ namespace Swift {
}
void IncomingWhiteboardSession::handleIncomingOperation(WhiteboardOperation::ref operation) {
-// std::cout << "incoming pos: " << operation->getPos() << std::endl;
-// WhiteboardInsertOperation::ref insertOp = boost::dynamic_pointer_cast<WhiteboardInsertOperation>(operation);
- WhiteboardOperation::ref op = server.handleClientOperationReceived(operation);
-/* server.print();
- std::cout << "in1: " << operation->getID() << " " << operation->getPos() << " " << operation->getParentID() << std::endl;
-// std::cout << "sin2: " << op->getID() << " " << op->getPos() << " " << op->getParentID() << std::endl;
- //std::cout << "in1: " << operation->getID() << " " << operation->getPos() << " " << operation->getParentID() << std::endl;
-
- WhiteboardInsertOperation::ref insertOp = boost::dynamic_pointer_cast<WhiteboardInsertOperation>(op);
- if (insertOp) {
- std::cout << "iin2: " << insertOp->getID() << " " << insertOp->getPos() << " " << insertOp->getParentID() << std::endl;
+ WhiteboardClient::Result pairResult = client.handleServerOperationReceived(operation);
+ if (pairResult.client) {
+ onOperationReceived(pairResult.client);
}
- WhiteboardUpdateOperation::ref updateOp = boost::dynamic_pointer_cast<WhiteboardUpdateOperation>(op);
- if (updateOp) {
- std::cout << "uin2: " << updateOp->getID() << " " << updateOp->getPos() << " " << updateOp->getParentID() << std::endl;
+ if (pairResult.server) {
+ WhiteboardPayload::ref payload = boost::make_shared<WhiteboardPayload>();
+ payload->setOperation(pairResult.server);
+ sendPayload(payload);
}
-
- WhiteboardDeleteOperation::ref deleteOp = boost::dynamic_pointer_cast<WhiteboardDeleteOperation>(op);
- if (deleteOp) {
- std::cout << "din2: " << deleteOp->getID() << " " << deleteOp->getPos() << " " << deleteOp->getParentID() << std::endl;
- }*/
-
- onOperationReceived(op);
-
- WhiteboardPayload::ref payload = boost::make_shared<WhiteboardPayload>();
- payload->setOperation(op);
- sendPayload(payload);
}
void IncomingWhiteboardSession::sendOperation(WhiteboardOperation::ref operation) {
-// std::cout << "out: " << operation->getID() << " " << operation->getPos() << " " << operation->getParentID()<< std::endl;
-
-/* WhiteboardInsertOperation::ref insertOp = boost::dynamic_pointer_cast<WhiteboardInsertOperation>(operation);
- if (insertOp) {
- std::cout << "iout: " << insertOp->getID() << " " << insertOp->getPos() << " " << insertOp->getParentID() << std::endl;
- }
-
- WhiteboardUpdateOperation::ref updateOp = boost::dynamic_pointer_cast<WhiteboardUpdateOperation>(operation);
- if (updateOp) {
- std::cout << "uout: " << updateOp->getID() << " " << updateOp->getPos() << " " << updateOp->getParentID() << std::endl;
- }
+ WhiteboardOperation::ref result = client.handleLocalOperationReceived(operation);
- WhiteboardDeleteOperation::ref deleteOp = boost::dynamic_pointer_cast<WhiteboardDeleteOperation>(operation);
- if (deleteOp) {
- std::cout << "dout: " << deleteOp->getID() << " " << deleteOp->getPos() << " " << deleteOp->getParentID() << std::endl;
+ if (result) {
+ WhiteboardPayload::ref payload = boost::make_shared<WhiteboardPayload>();
+ payload->setOperation(result);
+ sendPayload(payload);
}
-*/
- server.handleLocalOperationReceived(operation);
- WhiteboardPayload::ref payload = boost::make_shared<WhiteboardPayload>();
- payload->setOperation(operation);
- sendPayload(payload);
}
}
diff --git a/Swiften/Whiteboard/IncomingWhiteboardSession.h b/Swiften/Whiteboard/IncomingWhiteboardSession.h
index 99d3e44..567b851 100644
--- a/Swiften/Whiteboard/IncomingWhiteboardSession.h
+++ b/Swiften/Whiteboard/IncomingWhiteboardSession.h
@@ -7,7 +7,7 @@
#pragma once
#include <Swiften/Whiteboard/WhiteboardSession.h>
-#include <Swiften/Whiteboard/WhiteboardServer.h>
+#include <Swiften/Whiteboard/WhiteboardClient.h>
#include <boost/shared_ptr.hpp>
namespace Swift {
@@ -26,6 +26,6 @@ namespace Swift {
void handleIncomingOperation(WhiteboardOperation::ref operation);
void sendOperation(WhiteboardOperation::ref operation);
- WhiteboardServer server;
+ WhiteboardClient client;
};
}
diff --git a/Swiften/Whiteboard/OutgoingWhiteboardSession.cpp b/Swiften/Whiteboard/OutgoingWhiteboardSession.cpp
index ae07822..c527942 100644
--- a/Swiften/Whiteboard/OutgoingWhiteboardSession.cpp
+++ b/Swiften/Whiteboard/OutgoingWhiteboardSession.cpp
@@ -39,60 +39,19 @@ namespace Swift {
}
void OutgoingWhiteboardSession::handleIncomingOperation(WhiteboardOperation::ref operation) {
-// std::cout << "incoming pos: " << operation->getPos() << std::endl;
-// client.print();
+ WhiteboardOperation::ref op = server.handleClientOperationReceived(operation);
- WhiteboardClient::Result pairResult = client.handleServerOperationReceived(operation);
- if (pairResult.client) {
-/* WhiteboardInsertOperation::ref insertOp = boost::dynamic_pointer_cast<WhiteboardInsertOperation>(operation);
- if (insertOp) {
- std::cout << "iin1: " << insertOp->getID() << " " << insertOp->getPos() << " " << insertOp->getParentID() << std::endl;
- }
+ onOperationReceived(op);
- WhiteboardUpdateOperation::ref updateOp = boost::dynamic_pointer_cast<WhiteboardUpdateOperation>(operation);
- if (updateOp) {
- std::cout << "uin1: " << updateOp->getID() << " " << updateOp->getPos() << " " << updateOp->getParentID() << std::endl;
- }
-
- WhiteboardDeleteOperation::ref deleteOp = boost::dynamic_pointer_cast<WhiteboardDeleteOperation>(operation);
- if (deleteOp) {
- std::cout << "din1: " << deleteOp->getID() << " " << deleteOp->getPos() << " " << deleteOp->getParentID() << std::endl;
- }
-
- insertOp = boost::dynamic_pointer_cast<WhiteboardInsertOperation>(pairResult.client);
- if (insertOp) {
- std::cout << "iin1: " << insertOp->getID() << " " << insertOp->getPos() << " " << insertOp->getParentID() << std::endl;
- }
-
- updateOp = boost::dynamic_pointer_cast<WhiteboardUpdateOperation>(pairResult.client);
- if (updateOp) {
- std::cout << "uin1: " << updateOp->getID() << " " << updateOp->getPos() << " " << updateOp->getParentID() << std::endl;
- }
-
- deleteOp = boost::dynamic_pointer_cast<WhiteboardDeleteOperation>(pairResult.client);
- if (deleteOp) {
- std::cout << "din1: " << deleteOp->getID() << " " << deleteOp->getPos() << " " << deleteOp->getParentID() << std::endl;
- }*/
- onOperationReceived(pairResult.client);
- }
-
- if (pairResult.server) {
- //std::cout << "outts: " << pairResult.server->getID() << " " << pairResult.server->getPos() << std::endl;
- WhiteboardPayload::ref payload = boost::make_shared<WhiteboardPayload>();
- payload->setOperation(pairResult.server);
- sendPayload(payload);
- }
+ WhiteboardPayload::ref payload = boost::make_shared<WhiteboardPayload>();
+ payload->setOperation(op);
+ sendPayload(payload);
}
void OutgoingWhiteboardSession::sendOperation(WhiteboardOperation::ref operation) {
- //std::cout << "out1: " << operation->getID() << " " << operation->getPos() << " " << operation->getParentID() << std::endl;
- WhiteboardOperation::ref result = client.handleLocalOperationReceived(operation);
-
- if (result) {
- //std::cout << "out2: " << result->getID() << " " << result->getPos()<< " " << result->getParentID()<< std::endl;
- WhiteboardPayload::ref payload = boost::make_shared<WhiteboardPayload>();
- payload->setOperation(result);
- sendPayload(payload);
- }
+ server.handleLocalOperationReceived(operation);
+ WhiteboardPayload::ref payload = boost::make_shared<WhiteboardPayload>();
+ payload->setOperation(operation);
+ sendPayload(payload);
}
}
diff --git a/Swiften/Whiteboard/OutgoingWhiteboardSession.h b/Swiften/Whiteboard/OutgoingWhiteboardSession.h
index 149e483..fb9caed 100644
--- a/Swiften/Whiteboard/OutgoingWhiteboardSession.h
+++ b/Swiften/Whiteboard/OutgoingWhiteboardSession.h
@@ -7,7 +7,7 @@
#pragma once
#include <Swiften/Whiteboard/WhiteboardSession.h>
-#include <Swiften/Whiteboard/WhiteboardClient.h>
+#include <Swiften/Whiteboard/WhiteboardServer.h>
#include <boost/shared_ptr.hpp>
#include <Swiften/Queries/GenericRequest.h>
@@ -27,6 +27,6 @@ namespace Swift {
void handleIncomingOperation(WhiteboardOperation::ref operation);
void sendOperation(WhiteboardOperation::ref operation);
- WhiteboardClient client;
+ WhiteboardServer server;
};
}