| host.hpp | | host.hpp | |
| | | | |
| skipping to change at line 39 | | skipping to change at line 39 | |
| */ | | */ | |
| | | | |
| template<typename selector_type = net6::selector> | | template<typename selector_type = net6::selector> | |
| class basic_host | | class basic_host | |
| : virtual public basic_local<selector_type>, | | : virtual public basic_local<selector_type>, | |
| virtual public basic_server<selector_type> | | virtual public basic_server<selector_type> | |
| { | | { | |
| public: | | public: | |
| /** Creates a new basic_host object. | | /** Creates a new basic_host object. | |
| * @param username user name to use for the local user. | | * @param username user name to use for the local user. | |
|
| * @param ipv6 Whether to use IPv6. | | * @param ipv6 Whether to use IPv6 when no parameter is given to | |
| | | * reopen. | |
| */ | | */ | |
| basic_host(const std::string& username, bool ipv6 = true); | | basic_host(const std::string& username, bool ipv6 = true); | |
| | | | |
| /** Creates a new basic_host object which will accept incoming | | /** Creates a new basic_host object which will accept incoming | |
| * connections on port <em>port</em> and use the user name | | * connections on port <em>port</em> and use the user name | |
| * <em>username</em> for the local user. | | * <em>username</em> for the local user. | |
| */ | | */ | |
| basic_host(unsigned int port, const std::string& username, | | basic_host(unsigned int port, const std::string& username, | |
| bool ipv6 = true); | | bool ipv6 = true); | |
| | | | |
| | | | |
End of changes. 1 change blocks. |
| 1 lines changed or deleted | | 2 lines changed or added | |
|
| server.hpp | | server.hpp | |
| | | | |
| skipping to change at line 86 | | skipping to change at line 86 | |
| typedef sigc::signal<void, const user&, const packet&> | | typedef sigc::signal<void, const user&, const packet&> | |
| signal_login_type; | | signal_login_type; | |
| | | | |
| typedef sigc::signal<void, const user&, packet&> | | typedef sigc::signal<void, const user&, packet&> | |
| signal_login_extend_type; | | signal_login_extend_type; | |
| | | | |
| typedef sigc::signal<void, const user&, const packet&> | | typedef sigc::signal<void, const user&, const packet&> | |
| signal_data_type; | | signal_data_type; | |
| | | | |
| /** Creates a new basic_server object. | | /** Creates a new basic_server object. | |
|
| * @param ipv6 Whether to use IPv6. | | * @param ipv6 Whether to use IPv6 when no ipv6 parameter is given | |
| | | * to reopen. | |
| */ | | */ | |
| basic_server(bool ipv6 = true); | | basic_server(bool ipv6 = true); | |
| | | | |
| /** Creates a new basic_server which will be opened on port | | /** Creates a new basic_server which will be opened on port | |
| * <em>port</em>. | | * <em>port</em>. | |
| */ | | */ | |
| basic_server(unsigned int port, bool ipv6 = true); | | basic_server(unsigned int port, bool ipv6 = true); | |
| virtual ~basic_server(); | | virtual ~basic_server(); | |
| | | | |
|
| | | void reopen(unsigned int port) { reopen(port, use_ipv6); } | |
| | | | |
| /** (re)opens the server socket on port <em>port</em>, if it has | | /** (re)opens the server socket on port <em>port</em>, if it has | |
| * been shut down before. | | * been shut down before. | |
| */ | | */ | |
|
| virtual void reopen(unsigned int port); | | virtual void reopen(unsigned int port, bool ipv6); | |
| | | | |
| /** Shuts down the server socket. New connections will no longer be | | /** Shuts down the server socket. New connections will no longer be | |
| * accepted, but already established connections stay open. | | * accepted, but already established connections stay open. | |
| */ | | */ | |
| virtual void shutdown(); | | virtual void shutdown(); | |
| | | | |
| /** Returns whether the server socket has been opened. Note that the | | /** Returns whether the server socket has been opened. Note that the | |
| * socket may not be open but there are still client connections if
the | | * socket may not be open but there are still client connections if
the | |
| * server has been shut down when clients were connected. | | * server has been shut down when clients were connected. | |
| */ | | */ | |
| | | | |
| skipping to change at line 240 | | skipping to change at line 243 | |
| signal_disconnect_type signal_disconnect; | | signal_disconnect_type signal_disconnect; | |
| signal_join_type signal_join; | | signal_join_type signal_join; | |
| signal_part_type signal_part; | | signal_part_type signal_part; | |
| signal_login_auth_type signal_login_auth; | | signal_login_auth_type signal_login_auth; | |
| signal_login_type signal_login; | | signal_login_type signal_login; | |
| signal_login_extend_type signal_login_extend; | | signal_login_extend_type signal_login_extend; | |
| signal_data_type signal_data; | | signal_data_type signal_data; | |
| | | | |
| private: | | private: | |
| void shutdown_impl(); | | void shutdown_impl(); | |
|
| void reopen_impl(unsigned int port); | | void reopen_impl(unsigned int port, bool use_ipv6); | |
| }; | | }; | |
| | | | |
| typedef basic_server<selector> server; | | typedef basic_server<selector> server; | |
| | | | |
| template<typename selector_type> | | template<typename selector_type> | |
| basic_server<selector_type>::basic_server(bool ipv6) | | basic_server<selector_type>::basic_server(bool ipv6) | |
|
| : use_ipv6(ipv6), id_counter(0) | | : id_counter(0), use_ipv6(ipv6) | |
| { | | { | |
| } | | } | |
| | | | |
| template<typename selector_type> | | template<typename selector_type> | |
| basic_server<selector_type>::basic_server(unsigned int port, bool ipv6) | | basic_server<selector_type>::basic_server(unsigned int port, bool ipv6) | |
|
| : use_ipv6(ipv6), id_counter(0) | | : id_counter(0), use_ipv6(ipv6) | |
| { | | { | |
|
| reopen_impl(port); | | reopen_impl(port, ipv6); | |
| } | | } | |
| | | | |
| template<typename selector_type> | | template<typename selector_type> | |
| basic_server<selector_type>::~basic_server() | | basic_server<selector_type>::~basic_server() | |
| { | | { | |
| // TODO: Call user_clear first to remove user connections first? | | // TODO: Call user_clear first to remove user connections first? | |
| if(is_open() ) | | if(is_open() ) | |
| shutdown_impl(); | | shutdown_impl(); | |
| } | | } | |
| | | | |
| template<typename selector_type> | | template<typename selector_type> | |
|
| void basic_server<selector_type>::reopen(unsigned int port) | | void basic_server<selector_type>::reopen(unsigned int port, bool ipv6) | |
| { | | { | |
|
| reopen_impl(port); | | reopen_impl(port, ipv6); | |
| } | | } | |
| | | | |
| template<typename selector_type> | | template<typename selector_type> | |
| void basic_server<selector_type>::shutdown() | | void basic_server<selector_type>::shutdown() | |
| { | | { | |
| shutdown_impl(); | | shutdown_impl(); | |
| } | | } | |
| | | | |
| template<typename selector_type> | | template<typename selector_type> | |
| bool basic_server<selector_type>::is_open() const | | bool basic_server<selector_type>::is_open() const | |
| | | | |
| skipping to change at line 649 | | skipping to change at line 652 | |
| } | | } | |
| | | | |
| if(serv6_sock.get() != NULL) | | if(serv6_sock.get() != NULL) | |
| { | | { | |
| selector.set(*serv6_sock, IO_NONE); | | selector.set(*serv6_sock, IO_NONE); | |
| serv6_sock.reset(NULL); | | serv6_sock.reset(NULL); | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename selector_type> | | template<typename selector_type> | |
|
| void basic_server<selector_type>::reopen_impl(unsigned int port) | | void basic_server<selector_type>::reopen_impl(unsigned int port, bool ipv6) | |
| { | | { | |
| selector_type& selector = basic_object<selector_type>::get_selector(
); | | selector_type& selector = basic_object<selector_type>::get_selector(
); | |
| | | | |
| // Open IPv4 socket on local port | | // Open IPv4 socket on local port | |
|
| if(!use_ipv6) | | if(!ipv6) | |
| { | | { | |
| ipv4_address bind_addr(port); | | ipv4_address bind_addr(port); | |
| serv_sock.reset(new tcp_server_socket(bind_addr) ); | | serv_sock.reset(new tcp_server_socket(bind_addr) ); | |
| | | | |
| selector.set(*serv_sock, | | selector.set(*serv_sock, | |
| selector.get(*serv_sock) | IO_INCOMING | | selector.get(*serv_sock) | IO_INCOMING | |
| ); | | ); | |
| | | | |
| serv_sock->io_event().connect( | | serv_sock->io_event().connect( | |
| sigc::bind<0>( | | sigc::bind<0>( | |
| | | | |
End of changes. 11 change blocks. |
| 10 lines changed or deleted | | 13 lines changed or added | |
|