From 9d47ed3d783da724c653a17619df904fa7986be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Sun, 12 Jul 2009 15:37:21 +0200 Subject: Created IncomingConnection & ConnectionServer. diff --git a/Limber/main.cpp b/Limber/main.cpp index bc061e5..0893fc8 100644 --- a/Limber/main.cpp +++ b/Limber/main.cpp @@ -11,6 +11,8 @@ #include "Swiften/Base/ByteArray.h" #include "Swiften/EventLoop/MainEventLoop.h" #include "Swiften/EventLoop/SimpleEventLoop.h" +#include "Swiften/Network/IncomingConnection.h" +#include "Swiften/Network/ConnectionServer.h" using namespace Swift; @@ -33,7 +35,7 @@ class SharedBuffer { boost::asio::const_buffer buffer_; }; -class IncomingBoostConnection : public boost::enable_shared_from_this { +class IncomingBoostConnection : public IncomingConnection, public boost::enable_shared_from_this { public: typedef boost::shared_ptr pointer; @@ -64,7 +66,6 @@ class IncomingBoostConnection : public boost::enable_shared_from_this onNewConnection; - private: // Called from Asio thread void acceptNextConnection() { @@ -119,7 +118,7 @@ class BoostConnectionServer { boost::asio::ip::tcp::acceptor acceptor_; }; -void doSomething(IncomingBoostConnection::pointer c) { +void doSomething(boost::shared_ptr c) { c->write("Hello\n"); } diff --git a/Swiften/Network/ConnectionServer.cpp b/Swiften/Network/ConnectionServer.cpp new file mode 100644 index 0000000..7f63fee --- /dev/null +++ b/Swiften/Network/ConnectionServer.cpp @@ -0,0 +1,8 @@ +#include "Swiften/Network/ConnectionServer.h" + +namespace Swift { + +ConnectionServer::~ConnectionServer() { +} + +} diff --git a/Swiften/Network/ConnectionServer.h b/Swiften/Network/ConnectionServer.h new file mode 100644 index 0000000..d376308 --- /dev/null +++ b/Swiften/Network/ConnectionServer.h @@ -0,0 +1,15 @@ +#pragma once + +#include +#include + +#include "Swiften/Network/IncomingConnection.h" + +namespace Swift { + class ConnectionServer { + public: + virtual ~ConnectionServer(); + + boost::signal)> onNewConnection; + }; +} diff --git a/Swiften/Network/IncomingConnection.cpp b/Swiften/Network/IncomingConnection.cpp new file mode 100644 index 0000000..669f68e --- /dev/null +++ b/Swiften/Network/IncomingConnection.cpp @@ -0,0 +1,8 @@ +#include "Swiften/Network/IncomingConnection.h" + +namespace Swift { + +IncomingConnection::~IncomingConnection() { +} + +} diff --git a/Swiften/Network/IncomingConnection.h b/Swiften/Network/IncomingConnection.h new file mode 100644 index 0000000..eaa2ad6 --- /dev/null +++ b/Swiften/Network/IncomingConnection.h @@ -0,0 +1,17 @@ +#pragma once + +#include + +#include "Swiften/Base/ByteArray.h" + +namespace Swift { + class IncomingConnection { + public: + virtual ~IncomingConnection(); + + virtual void write(const ByteArray& data) = 0; + + //boost::signal onError; + boost::signal onDataRead; + }; +} diff --git a/Swiften/Network/Makefile.inc b/Swiften/Network/Makefile.inc index 17b2838..b0f0fd1 100644 --- a/Swiften/Network/Makefile.inc +++ b/Swiften/Network/Makefile.inc @@ -4,6 +4,8 @@ SWIFTEN_SOURCES += \ Swiften/Network/ConnectionFactory.cpp \ Swiften/Network/BoostConnection.cpp \ Swiften/Network/BoostConnectionFactory.cpp \ + Swiften/Network/ConnectionServer.cpp \ + Swiften/Network/IncomingConnection.cpp \ Swiften/Network/Timer.cpp include Swiften/Network/UnitTest/Makefile.inc -- cgit v0.10.2-6-g49f6