Skip to content

Commit

Permalink
Rename connection -> connection_in
Browse files Browse the repository at this point in the history
  • Loading branch information
ddaeschler committed Oct 10, 2014
1 parent 4a2b999 commit 1b82fa7
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 41 deletions.
20 changes: 10 additions & 10 deletions node/src/connection.cpp → node/src/connection_in.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

#include "connection.h"
#include "connection_in.h"

#include "server.h"
#include "logging.h"
Expand All @@ -34,22 +34,22 @@ namespace sopmq {
namespace node {
namespace connection {

connection::connection(ba::io_service& ioService)
connection_in::connection_in(ba::io_service& ioService)
: _ioService(ioService), _conn(_ioService), _next_id(0)
{

}

connection::~connection()
connection_in::~connection_in()
{
}

ba::ip::tcp::socket& connection::get_socket()
ba::ip::tcp::socket& connection_in::get_socket()
{
return _conn;
}

void connection::start(server* server)
void connection_in::start(server* server)
{
_server = server;
_server->connection_started(shared_from_this());
Expand All @@ -67,14 +67,14 @@ namespace sopmq {
_state->start();
}

void connection::handle_error(const network_error& e)
void connection_in::handle_error(const network_error& e)
{
LOG_SRC(error) << "network error: " << e.what() << ". closing connection";

this->close();
}

void connection::close()
void connection_in::close()
{
//we really don't care about errors here
boost::system::error_code ec;
Expand All @@ -83,19 +83,19 @@ namespace sopmq {
_server->connection_terminated(shared_from_this());
}

std::uint32_t connection::get_next_id()
std::uint32_t connection_in::get_next_id()
{
return ++_next_id;
}

void connection::send_message(message_type type, Message_ptr message,
void connection_in::send_message(message_type type, Message_ptr message,
network_status_callback statusCb)
{
messageutil::write_message(type, message, _ioService, _conn,
statusCb);
}

void connection::change_state(iconnection_state::ptr newState)
void connection_in::change_state(iconnection_state::ptr newState)
{
_state = newState;
_state->start();
Expand Down
14 changes: 7 additions & 7 deletions node/src/connection.h → node/src/connection_in.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ namespace sopmq {
namespace connection {

///
/// Connections from clients or other servers to this server
/// Connections from clients or other servers into to this server
///
class connection : public boost::noncopyable,
public std::enable_shared_from_this<connection>
class connection_in : public boost::noncopyable,
public std::enable_shared_from_this<connection_in>
{
public:
typedef std::shared_ptr<connection> ptr;
typedef std::weak_ptr<connection> wptr;
typedef std::shared_ptr<connection_in> ptr;
typedef std::weak_ptr<connection_in> wptr;

public:
connection(boost::asio::io_service& ioService);
virtual ~connection();
connection_in(boost::asio::io_service& ioService);
virtual ~connection_in();

///
/// Returns the TCP socket associated with this connection
Expand Down
4 changes: 2 additions & 2 deletions node/src/csauthenticated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace sopmq {
namespace node {
namespace connection {

csauthenticated::csauthenticated(boost::asio::io_service& ioService, connection::wptr conn)
csauthenticated::csauthenticated(boost::asio::io_service& ioService, connection_in::wptr conn)
: _ioService(ioService), _conn(conn),
_dispatcher(std::bind(&csauthenticated::unhandled_message, this, _1))
{
Expand Down Expand Up @@ -68,7 +68,7 @@ namespace sopmq {
}
}

void csauthenticated::read_next_message(connection::ptr conn)
void csauthenticated::read_next_message(connection_in::ptr conn)
{
messageutil::read_message(_ioService, conn->get_socket(),
std::bind(&csauthenticated::handle_read_result, shared_from_this(), _1),
Expand Down
8 changes: 4 additions & 4 deletions node/src/csauthenticated.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "iconnection_state.h"

#include "connection.h"
#include "connection_in.h"
#include "message_dispatcher.h"
#include "network_operation_result.h"
#include "message_ptrs.h"
Expand All @@ -40,7 +40,7 @@ namespace sopmq {
public std::enable_shared_from_this<csauthenticated>
{
public:
csauthenticated(boost::asio::io_service& ioService, connection::wptr conn);
csauthenticated(boost::asio::io_service& ioService, connection_in::wptr conn);
virtual ~csauthenticated();

//iconnection_state
Expand All @@ -50,13 +50,13 @@ namespace sopmq {

private:
boost::asio::io_service& _ioService;
connection::wptr _conn;
connection_in::wptr _conn;
sopmq::message::message_dispatcher _dispatcher;


void unhandled_message(Message_ptr message);

void read_next_message(connection::ptr conn);
void read_next_message(connection_in::ptr conn);

void handle_read_result(const net::network_operation_result& result);

Expand Down
6 changes: 3 additions & 3 deletions node/src/csunauthenticated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace sopmq {

const int csunauthenticated::CHALLENGE_SIZE = 1024;

csunauthenticated::csunauthenticated(ba::io_service& ioService, connection::wptr conn)
csunauthenticated::csunauthenticated(ba::io_service& ioService, connection_in::wptr conn)
: _ioService(ioService), _conn(conn),
_dispatcher(std::bind(&csunauthenticated::unhandled_message, this, _1)),
_closeAfterTransmission(false)
Expand Down Expand Up @@ -85,7 +85,7 @@ namespace sopmq {
}
}

void csunauthenticated::generate_challenge_response(connection::ptr conn, std::uint32_t replyTo)
void csunauthenticated::generate_challenge_response(connection_in::ptr conn, std::uint32_t replyTo)
{
ChallengeResponseMessage_ptr response = messageutil::make_message<ChallengeResponseMessage>(conn->get_next_id(), replyTo);

Expand Down Expand Up @@ -196,7 +196,7 @@ namespace sopmq {
return "unauthenticated";
}

void csunauthenticated::read_next_message(connection::ptr conn)
void csunauthenticated::read_next_message(connection_in::ptr conn)
{
//read a message from the network
messageutil::read_message(_ioService, conn->get_socket(),
Expand Down
10 changes: 5 additions & 5 deletions node/src/csunauthenticated.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define __sopmq__csunauthenticated__

#include "iconnection_state.h"
#include "connection.h"
#include "connection_in.h"
#include "message_dispatcher.h"
#include "message_ptrs.h"
#include "network_operation_result.h"
Expand All @@ -44,7 +44,7 @@ namespace sopmq {
public std::enable_shared_from_this<csunauthenticated>
{
public:
csunauthenticated(boost::asio::io_service& ioService, connection::wptr conn);
csunauthenticated(boost::asio::io_service& ioService, connection_in::wptr conn);
virtual ~csunauthenticated();


Expand All @@ -61,7 +61,7 @@ namespace sopmq {


boost::asio::io_service& _ioService;
connection::wptr _conn;
connection_in::wptr _conn;
sopmq::message::message_dispatcher _dispatcher;
GetChallengeMessage_Type _authType;

Expand All @@ -75,9 +75,9 @@ namespace sopmq {

void handle_read_result(const net::network_operation_result& result);

void generate_challenge_response(connection::ptr conn, std::uint32_t replyTo);
void generate_challenge_response(connection_in::ptr conn, std::uint32_t replyTo);

void read_next_message(connection::ptr conn);
void read_next_message(connection_in::ptr conn);

void handle_answer_challenge_message(AnswerChallengeMessage_ptr message);

Expand Down
10 changes: 5 additions & 5 deletions node/src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "server.h"

#include "connection.h"
#include "connection_in.h"

#include <boost/bind.hpp>
#include <boost/log/trivial.hpp>
Expand Down Expand Up @@ -47,7 +47,7 @@ namespace sopmq {

void server::accept_new()
{
connection::connection::ptr conn(std::make_shared<connection::connection>(_ioService));
connection::connection_in::ptr conn(std::make_shared<connection::connection_in>(_ioService));

_acceptor.async_accept(conn->get_socket(),
boost::bind(&server::handle_accept, this, conn,
Expand All @@ -60,7 +60,7 @@ namespace sopmq {
_acceptor.close();
}

void server::handle_accept(connection::connection::ptr conn, const boost::system::error_code& error)
void server::handle_accept(connection::connection_in::ptr conn, const boost::system::error_code& error)
{
if (_stopping) return;

Expand All @@ -83,12 +83,12 @@ namespace sopmq {
}
}

void server::connection_started(connection::connection::ptr conn)
void server::connection_started(connection::connection_in::ptr conn)
{
_connections.insert(conn);
}

void server::connection_terminated(connection::connection::ptr conn)
void server::connection_terminated(connection::connection_in::ptr conn)
{
_connections.erase(conn);
}
Expand Down
10 changes: 5 additions & 5 deletions node/src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#ifndef __sopmq__server__
#define __sopmq__server__

#include "connection.h"
#include "connection_in.h"

#include <boost/asio.hpp>
#include <boost/noncopyable.hpp>
Expand Down Expand Up @@ -48,24 +48,24 @@ namespace sopmq {
///
/// Called when a connection has been started and is alive
///
void connection_started(connection::connection::ptr conn);
void connection_started(connection::connection_in::ptr conn);

///
/// Called when a connection has been terminated either locally or remotely
///
void connection_terminated(connection::connection::ptr conn);
void connection_terminated(connection::connection_in::ptr conn);

private:
boost::asio::io_service& _ioService;
unsigned short _port;
boost::asio::ip::tcp::endpoint _endpoint;
boost::asio::ip::tcp::acceptor _acceptor;
std::set<connection::connection::ptr> _connections;
std::set<connection::connection_in::ptr> _connections;
bool _stopping;


void accept_new();
void handle_accept(connection::connection::ptr conn, const boost::system::error_code& error);
void handle_accept(connection::connection_in::ptr conn, const boost::system::error_code& error);
};

}
Expand Down

0 comments on commit 1b82fa7

Please sign in to comment.