Changeset - b9d0590c67f8
[Not reviewed]
0 0 4
Vitaly Takmazov - 10 years ago 2015-10-15 13:53:08
vitalyster@gmail.com
fix tests WIP
4 files changed with 140 insertions and 0 deletions:
0 comments (0 inline, 0 general)
include/Swiften/Network/DummyConnectionServer.cpp
Show inline comments
 
new file 100644
 
/*
 
 * 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();
 
}
 

	
 
}
include/Swiften/Network/DummyConnectionServer.h
Show inline comments
 
new file 100644
 
/*
 
 * 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;
 
	};
 
}
include/Swiften/Network/DummyConnectionServerFactory.cpp
Show inline comments
 
new file 100644
 
/*
 
 * 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);
 
}
 

	
 
}
include/Swiften/Network/DummyConnectionServerFactory.h
Show inline comments
 
new file 100644
 
/*
 
 * 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;
 
	};
 
}
0 comments (0 inline, 0 general)