Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Dec 11, 2012
2 parents 47be867 + 2505b6e commit f16d6f9
Show file tree
Hide file tree
Showing 34 changed files with 1,948 additions and 1,142 deletions.
13 changes: 9 additions & 4 deletions BoostConnect.sln
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BoostConnect", "include\boostconnect\BoostConnect.vcxproj", "{16641C79-954C-4833-80D4-64FDC908700B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sample", "sample\sample.vcxproj", "{EE6486AA-E297-45E8-BBEB-D54B5FD990DE}"
ProjectSection(ProjectDependencies) = postProject
{16641C79-954C-4833-80D4-64FDC908700B} = {16641C79-954C-4833-80D4-64FDC908700B}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boostconnect", "include\boostconnect\boostconnect.vcxproj", "{16641C79-954C-4833-80D4-64FDC908700B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{16641C79-954C-4833-80D4-64FDC908700B}.Debug|Win32.ActiveCfg = Debug|Win32
{16641C79-954C-4833-80D4-64FDC908700B}.Release|Win32.ActiveCfg = Release|Win32
{EE6486AA-E297-45E8-BBEB-D54B5FD990DE}.Debug|Win32.ActiveCfg = Debug|Win32
{EE6486AA-E297-45E8-BBEB-D54B5FD990DE}.Debug|Win32.Build.0 = Debug|Win32
{EE6486AA-E297-45E8-BBEB-D54B5FD990DE}.Release|Win32.ActiveCfg = Release|Win32
{EE6486AA-E297-45E8-BBEB-D54B5FD990DE}.Release|Win32.Build.0 = Release|Win32
{16641C79-954C-4833-80D4-64FDC908700B}.Debug|Win32.ActiveCfg = Debug|Win32
{16641C79-954C-4833-80D4-64FDC908700B}.Debug|Win32.Build.0 = Debug|Win32
{16641C79-954C-4833-80D4-64FDC908700B}.Release|Win32.ActiveCfg = Release|Win32
{16641C79-954C-4833-80D4-64FDC908700B}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
85 changes: 85 additions & 0 deletions include/boostconnect/application_layer/impl/socket_base.ipp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//
// socket_base.ipp
// ~~~~~~~~~~
//
// socket_baseの実装
//

#ifndef BOOSTCONNECT_APPLAYER_SOCKET_BASE_IPP
#define BOOSTCONNECT_APPLAYER_SOCKET_BASE_IPP

#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include "../socket_base.hpp"

namespace bstcon{
namespace application_layer{

//こいつらは無視の方針で(というかインターフェース)
socket_base::socket_base(){}
socket_base::~socket_base(){}

template<class Socket>
socket_common<Socket>::socket_common(io_service& io_service) : socket_(io_service)
{
}

#ifdef USE_SSL_BOOSTCONNECT
template<class Socket>
socket_common<Socket>::socket_common(io_service& io_service,context_type& ctx) : socket_(io_service,ctx)
{
}
#endif

template<class Socket>
socket_common<Socket>::~socket_common(){}

template<class Socket>
typename socket_common<Socket>::lowest_layer_type& socket_common<Socket>::lowest_layer()
{
return socket_.lowest_layer();
}
template<class Socket>
typename socket_common<Socket>::io_service& socket_common<Socket>::get_io_service()
{
return socket_.get_io_service();
}

template<class Socket>
std::size_t socket_common<Socket>::read_some(const mutable_buffer& buf,error_code& ec)
{
return socket_.read_some(buf,ec);
}
template<class Socket>
std::size_t socket_common<Socket>::write_some(const const_buffer& buf,error_code& ec)
{
return socket_.write_some(buf,ec);
}
template<class Socket>
std::size_t socket_common<Socket>::write_some(const consuming_buffer& buf,error_code& ec)
{
return socket_.write_some(buf,ec);
}
template<class Socket>
void socket_common<Socket>::async_read_some(const mutable_buffer& buf,ReadHandler handler)
{
socket_.async_read_some(buf,handler);
return;
}
template<class Socket>
void socket_common<Socket>::async_write_some(const const_buffer& buf,WriteHandler handler)
{
socket_.async_write_some(buf,handler);
return;
}
template<class Socket>
void socket_common<Socket>::async_write_some(const consuming_buffer& buf,WriteHandler handler)
{
socket_.async_write_some(buf,handler);
return;
}

} // namespace application_layer
} // namespace bstcon

#endif
71 changes: 71 additions & 0 deletions include/boostconnect/application_layer/impl/ssl_socket.ipp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// ssl_socket.ipp
// ~~~~~~~~~~
//
// ssl_socketの実装
//

#ifdef USE_SSL_BOOSTCONNECT
#ifndef BOOSTCONNECT_APPLAYER_SSL_SOCKET_IPP
#define BOOSTCONNECT_APPLAYER_SSL_SOCKET_IPP

#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#include "../ssl_socket.hpp"

namespace bstcon{
namespace application_layer{

ssl_socket::ssl_socket(io_service& io_service,context_type& ctx) : my_base(io_service,ctx)
{
}
ssl_socket::~ssl_socket()
{
}

const std::string ssl_socket::service_protocol() const
{
return "https";
}

//SSL通信のコネクション確立(TCPレイヤーでコネクションを行う)
ssl_socket::error_code& ssl_socket::connect(endpoint_type& begin,error_code& ec)
{
ec = socket_.lowest_layer().connect(begin,ec);
return ec;
}
void ssl_socket::async_connect(endpoint_type& begin,ConnectHandler handler)
{
socket_.lowest_layer().async_connect(begin,handler);
return;
}

void ssl_socket::handshake(handshake_type type)
{
socket_.handshake(type);
return;
}
void ssl_socket::async_handshake(handshake_type type,HandshakeHandler handler)
{
socket_.async_handshake(type,handler);
return;
}

//[(SSLレイヤーの処理 ->] TCPレイヤーの処理
void ssl_socket::close()
{
socket_.lowest_layer().close();
return;
}
void ssl_socket::shutdown(shutdown_type what)
{
socket_.shutdown();
socket_.lowest_layer().shutdown(what);
return;
}

} // namespace application_layer
} // namespace bstcon

#endif
#endif
77 changes: 77 additions & 0 deletions include/boostconnect/application_layer/impl/tcp_socket.ipp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//
// tcp_socket.ipp
// ~~~~~~~~~~
//
// tcp_socketの実装
//

#ifndef BOOSTCONNECT_APPLAYER_TCP_SOCKET_IPP
#define BOOSTCONNECT_APPLAYER_TCP_SOCKET_IPP

#include <boost/asio.hpp>
#include "../tcp_socket.hpp"

namespace bstcon{
namespace application_layer{

tcp_socket::tcp_socket(io_service& io_service) : my_base(io_service)
{
}
tcp_socket::~tcp_socket(){}

const std::string tcp_socket::service_protocol() const
{
return "http";
}

//TCP通信のコネクション確立
tcp_socket::error_code& tcp_socket::connect(endpoint_type& begin,error_code& ec)
{
ec = socket_.connect(begin,ec);
return ec;
}
void tcp_socket::async_connect(endpoint_type& begin,ConnectHandler handler)
{
socket_.async_connect(begin,handler);
return;
}

#ifdef USE_SSL_BOOSTCONNECT
//TCP通信ではHandshakeを行わない -> Handlerを直接呼び出す
void tcp_socket::handshake(handshake_type)
{
return;
}
void tcp_socket::async_handshake(handshake_type,HandshakeHandler handler)
{
handler(error_code());
return;
}
#else
void tcp_socket::handshake()
{
return;
}
void tcp_socket::async_handshake(HandshakeHandler handler)
{
handler(error_code());
return;
}
#endif

//TCPレイヤーの処理
void tcp_socket::close()
{
socket_.close();
return;
}
void tcp_socket::shutdown(shutdown_type what)
{
socket_.shutdown(what);
return;
}

} // namespace application_layer
} // namespace bstcon

#endif
65 changes: 20 additions & 45 deletions include/boostconnect/application_layer/socket_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
// ソケットラッパーベースクラス
//

#ifndef BOOSTCONNECT_APPLAYER_SOCKET_BASE
#define BOOSTCONNECT_APPLAYER_SOCKET_BASE
#ifndef BOOSTCONNECT_APPLAYER_SOCKET_BASE_HPP
#define BOOSTCONNECT_APPLAYER_SOCKET_BASE_HPP

#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/function.hpp>

#ifdef USE_SSL_BOOSTCONNECT
Expand Down Expand Up @@ -43,8 +42,8 @@ struct socket_base : boost::noncopyable{
typedef boost::function<void(const error_code&,std::size_t)> ReadHandler;
typedef boost::function<void(const error_code&,std::size_t)> WriteHandler;

socket_base(){}
virtual ~socket_base(){}
socket_base();
virtual ~socket_base();

virtual io_service& get_io_service() = 0;
virtual lowest_layer_type& lowest_layer() = 0;
Expand Down Expand Up @@ -77,51 +76,23 @@ struct socket_base : boost::noncopyable{
template<class Socket>
class socket_common : public socket_base{
public:
socket_common(io_service& io_service) : socket_(io_service){}
socket_common(io_service& io_service);

#ifdef USE_SSL_BOOSTCONNECT
socket_common(io_service& io_service,context_type& ctx) : socket_(io_service,ctx){}
socket_common(io_service& io_service,context_type& ctx);
#endif

virtual ~socket_common(){}
virtual ~socket_common();

lowest_layer_type& lowest_layer()
{
return socket_.lowest_layer();
}

io_service& get_io_service()
{
return socket_.get_io_service();
}

std::size_t read_some(const mutable_buffer& buf,error_code& ec)
{
return socket_.read_some(buf,ec);
}
std::size_t write_some(const const_buffer& buf,error_code& ec)
{
return socket_.write_some(buf,ec);
}
std::size_t write_some(const consuming_buffer& buf,error_code& ec)
{
return socket_.write_some(buf,ec);
}
void async_read_some(const mutable_buffer& buf,ReadHandler handler)
{
socket_.async_read_some(buf,handler);
return;
}
void async_write_some(const const_buffer& buf,WriteHandler handler)
{
socket_.async_write_some(buf,handler);
return;
}
void async_write_some(const consuming_buffer& buf,WriteHandler handler)
{
socket_.async_write_some(buf,handler);
return;
}
lowest_layer_type& lowest_layer();
io_service& get_io_service();

std::size_t read_some(const mutable_buffer& buf,error_code& ec);
std::size_t write_some(const const_buffer& buf,error_code& ec);
std::size_t write_some(const consuming_buffer& buf,error_code& ec);
void async_read_some(const mutable_buffer& buf,ReadHandler handler);
void async_write_some(const const_buffer& buf,WriteHandler handler);
void async_write_some(const consuming_buffer& buf,WriteHandler handler);

protected:
Socket socket_;
Expand All @@ -130,4 +101,8 @@ class socket_common : public socket_base{
} // namespace application_layer
} // namespace bstcon

#ifdef BOOSTCONNECT_LIB_BUILD
#include "impl/socket_base.ipp"
#endif

#endif
Loading

0 comments on commit f16d6f9

Please sign in to comment.