fix tests WIP
This commit is contained in:
parent
66a2834334
commit
b9d0590c67
4 changed files with 140 additions and 0 deletions
40
include/Swiften/Network/DummyConnectionServer.cpp
Normal file
40
include/Swiften/Network/DummyConnectionServer.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2010 Remko Tronçon
|
||||
* Licensed under the GNU General Public License v3.
|
||||
* See Documentation/Licenses/GPLv3.txt for more information.
|
||||
*/
|
||||
|
||||
#include <Swiften/Network/DummyConnectionServer.h>
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/system/system_error.hpp>
|
||||
#include <boost/asio/placeholders.hpp>
|
||||
|
||||
#include <Swiften/EventLoop/EventLoop.h>
|
||||
|
||||
namespace Swift {
|
||||
|
||||
DummyConnectionServer::DummyConnectionServer(EventLoop* eventLoop) : eventLoop(eventLoop) {
|
||||
}
|
||||
|
||||
void DummyConnectionServer::start() {
|
||||
}
|
||||
|
||||
|
||||
void DummyConnectionServer::stop() {
|
||||
|
||||
}
|
||||
|
||||
void DummyConnectionServer::acceptConnection(boost::shared_ptr<Connection> connection) {
|
||||
eventLoop->postEvent(
|
||||
boost::bind(boost::ref(onNewConnection), connection),
|
||||
shared_from_this());
|
||||
// connection->listen();
|
||||
}
|
||||
|
||||
|
||||
HostAddressPort DummyConnectionServer::getAddressPort() const {
|
||||
return HostAddressPort();
|
||||
}
|
||||
|
||||
}
|
49
include/Swiften/Network/DummyConnectionServer.h
Normal file
49
include/Swiften/Network/DummyConnectionServer.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2010 Remko Tronçon
|
||||
* Licensed under the GNU General Public License v3.
|
||||
* See Documentation/Licenses/GPLv3.txt for more information.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <Swiften/Base/boost_bsignals.h>
|
||||
|
||||
#include <Swiften/Network/DummyConnection.h>
|
||||
#include <Swiften/Network/ConnectionServer.h>
|
||||
#include <Swiften/EventLoop/EventOwner.h>
|
||||
|
||||
namespace Swift {
|
||||
class DummyConnectionServer : public ConnectionServer, public EventOwner, public boost::enable_shared_from_this<DummyConnectionServer> {
|
||||
public:
|
||||
typedef boost::shared_ptr<DummyConnectionServer> ref;
|
||||
|
||||
enum Error {
|
||||
Conflict,
|
||||
UnknownError
|
||||
};
|
||||
|
||||
static ref create(EventLoop* eventLoop) {
|
||||
return ref(new DummyConnectionServer(eventLoop));
|
||||
}
|
||||
|
||||
void acceptConnection(boost::shared_ptr<Connection> connection);
|
||||
|
||||
virtual void start();
|
||||
virtual void stop();
|
||||
|
||||
virtual HostAddressPort getAddressPort() const;
|
||||
|
||||
|
||||
private:
|
||||
DummyConnectionServer(EventLoop* eventLoop);
|
||||
|
||||
|
||||
private:
|
||||
HostAddress address_;
|
||||
EventLoop* eventLoop;
|
||||
};
|
||||
}
|
23
include/Swiften/Network/DummyConnectionServerFactory.cpp
Normal file
23
include/Swiften/Network/DummyConnectionServerFactory.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jan Kaluza
|
||||
* Licensed under the Simplified BSD license.
|
||||
* See Documentation/Licenses/BSD-simplified.txt for more information.
|
||||
*/
|
||||
|
||||
#include <Swiften/Network/DummyConnectionServerFactory.h>
|
||||
#include <Swiften/Network/DummyConnectionServer.h>
|
||||
|
||||
namespace Swift {
|
||||
|
||||
DummyConnectionServerFactory::DummyConnectionServerFactory(EventLoop* eventLoop) : eventLoop(eventLoop) {
|
||||
}
|
||||
|
||||
boost::shared_ptr<ConnectionServer> DummyConnectionServerFactory::createConnectionServer(int port) {
|
||||
return DummyConnectionServer::create(eventLoop);
|
||||
}
|
||||
|
||||
boost::shared_ptr<ConnectionServer> DummyConnectionServerFactory::createConnectionServer(const Swift::HostAddress &hostAddress, int port) {
|
||||
return DummyConnectionServer::create(eventLoop);
|
||||
}
|
||||
|
||||
}
|
28
include/Swiften/Network/DummyConnectionServerFactory.h
Normal file
28
include/Swiften/Network/DummyConnectionServerFactory.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jan Kaluza
|
||||
* Licensed under the Simplified BSD license.
|
||||
* See Documentation/Licenses/BSD-simplified.txt for more information.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <boost/asio/io_service.hpp>
|
||||
|
||||
#include <Swiften/Network/ConnectionServerFactory.h>
|
||||
#include <Swiften/Network/DummyConnectionServer.h>
|
||||
|
||||
namespace Swift {
|
||||
class ConnectionServer;
|
||||
|
||||
class DummyConnectionServerFactory : public ConnectionServerFactory {
|
||||
public:
|
||||
DummyConnectionServerFactory(EventLoop* eventLoop);
|
||||
|
||||
virtual boost::shared_ptr<ConnectionServer> createConnectionServer(int port);
|
||||
|
||||
virtual boost::shared_ptr<ConnectionServer> createConnectionServer(const Swift::HostAddress &hostAddress, int port);
|
||||
|
||||
private:
|
||||
EventLoop* eventLoop;
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue