irccd
3.0.3
|
The class that connect to a IRC server. More...
#include <server.hpp>
Public Types | |
enum class | options : std::uint8_t { none = 0 , ipv4 = (1 << 0) , ipv6 = (1 << 1) , ssl = (1 << 2) , auto_rejoin = (1 << 3) , auto_reconnect = (1 << 4) , join_invite = (1 << 5) } |
Various options for server. More... | |
enum class | state : std::uint8_t { disconnected , connecting , identifying , connected } |
Describe current server state. More... | |
using | connect_handler = std::function< void(std::error_code)> |
using | recv_handler = std::function< void(std::error_code, event)> |
Public Member Functions | |
server (boost::asio::io_service &service, std::string id, std::string hostname="localhost") | |
virtual | ~server () |
auto | get_state () const noexcept -> state |
auto | get_id () const noexcept -> const std::string & |
auto | get_hostname () const noexcept -> const std::string & |
auto | get_password () const noexcept -> const std::string & |
void | set_password (std::string password) noexcept |
auto | get_port () const noexcept -> std::uint16_t |
void | set_port (std::uint16_t port) noexcept |
auto | get_options () const noexcept -> options |
void | set_options (options flags) noexcept |
auto | get_nickname () const noexcept -> const std::string & |
void | set_nickname (std::string nickname) |
auto | get_username () const noexcept -> const std::string & |
void | set_username (std::string name) noexcept |
auto | get_realname () const noexcept -> const std::string & |
void | set_realname (std::string realname) noexcept |
auto | get_ctcp_version () const noexcept -> const std::string & |
void | set_ctcp_version (std::string ctcpversion) |
auto | get_command_char () const noexcept -> const std::string & |
void | set_command_char (std::string command_char) noexcept |
auto | get_reconnect_delay () const noexcept -> std::uint16_t |
void | set_reconnect_delay (std::uint16_t reconnect_delay) noexcept |
auto | get_ping_timeout () const noexcept -> std::uint16_t |
void | set_ping_timeout (std::uint16_t ping_timeout) noexcept |
auto | get_channels () const noexcept -> const std::set< std::string > & |
auto | is_self (std::string_view nick) const noexcept -> bool |
virtual void | connect (connect_handler handler) noexcept |
virtual void | disconnect () |
virtual void | wait (connect_handler handler) |
virtual void | recv (recv_handler handler) noexcept |
virtual void | invite (std::string_view target, std::string_view channel) |
virtual void | join (std::string_view channel, std::string_view password="") |
virtual void | kick (std::string_view target, std::string_view channel, std::string_view reason="") |
virtual void | me (std::string_view target, std::string_view message) |
virtual void | message (std::string_view target, std::string_view message) |
virtual void | mode (std::string_view channel, std::string_view mode, std::string_view limit="", std::string_view user="", std::string_view mask="") |
virtual void | names (std::string_view channel) |
virtual void | notice (std::string_view target, std::string_view message) |
virtual void | part (std::string_view channel, std::string_view reason="") |
virtual void | send (std::string_view raw) |
virtual void | topic (std::string_view channel, std::string_view topic) |
virtual void | whois (std::string_view target) |
Protected Attributes | |
state | state_ {state::disconnected} |
Server state. More... | |
The class that connect to a IRC server.
This class is higher level than irc connection, it does identify process, parsing message, translating messages and queue'ing user requests.
using irccd::daemon::server::connect_handler = std::function<void (std::error_code)> |
Completion handler once network connection is complete.
using irccd::daemon::server::recv_handler = std::function<void (std::error_code, event)> |
Completion handler once a network message has arrived.
|
strong |
|
strong |
irccd::daemon::server::server | ( | boost::asio::io_service & | service, |
std::string | id, | ||
std::string | hostname = "localhost" |
||
) |
Construct a server.
service | the service |
id | the identifier |
hostname | the hostname |
|
virtual |
Destructor. Close the connection if needed.
|
virtualnoexcept |
Start connecting.
This only initiate TCP connection and/or SSL handshaking, the identifying process may take some time and you must repeatedly call recv() to wait for connect_event.
handler | the completion handler |
Reimplemented in irccd::test::mock_server, and irccd::test::debug_server.
|
virtual |
Force disconnection.
Reimplemented in irccd::test::mock_server, and irccd::test::debug_server.
|
noexcept |
Get the list of channels joined.
|
noexcept |
Get the command character.
|
noexcept |
Get the CTCP version.
|
noexcept |
Get the hostname.
|
noexcept |
Get the server identifier.
|
noexcept |
Get the nickname.
|
noexcept |
Get the options flags.
|
noexcept |
Get the password.
|
noexcept |
Get the ping timeout.
|
noexcept |
Get the port.
|
noexcept |
Get the realname.
|
noexcept |
Get the reconnection delay before retrying.
|
noexcept |
Get the current server state.
|
noexcept |
Get the username.
|
virtual |
Invite a user to a channel.
target | the target nickname |
channel | the channel |
Reimplemented in irccd::test::mock_server, and irccd::test::debug_server.
|
noexcept |
Determine if the nickname is the bot itself.
nick | the nickname to check |
|
virtual |
Join a channel, the password is optional and can be kept empty.
channel | the channel to join |
password | the optional password |
Reimplemented in irccd::test::mock_server, and irccd::test::debug_server.
|
virtual |
Kick someone from the channel. Please be sure to have the rights on that channel because errors won't be reported.
target | the target to kick |
channel | from which channel |
reason | the optional reason |
Reimplemented in irccd::test::mock_server, and irccd::test::debug_server.
|
virtual |
Send a CTCP Action as known as /me. The target may be either a channel or a nickname.
target | the nickname or the channel |
message | the message |
Reimplemented in irccd::test::mock_server, and irccd::test::debug_server.
|
virtual |
Send a message to the specified target or channel.
target | the target |
message | the message |
Reimplemented in irccd::test::mock_server, and irccd::test::debug_server.
|
virtual |
Change channel/user mode.
channel | the channel or nickname |
mode | the mode |
limit | the optional limit |
user | the optional user |
mask | the optional ban mask |
Reimplemented in irccd::test::mock_server, and irccd::test::debug_server.
|
virtual |
Request the list of names.
channel | the channel |
Reimplemented in irccd::test::mock_server, and irccd::test::debug_server.
|
virtual |
Send a private notice.
target | the target |
message | the notice message |
Reimplemented in irccd::test::mock_server, and irccd::test::debug_server.
|
virtual |
Part from a channel.
Please note that the reason is not supported on all servers so if you want portability, don't provide it.
channel | the channel to leave |
reason | the optional reason |
Reimplemented in irccd::test::mock_server, and irccd::test::debug_server.
|
virtualnoexcept |
Receive next event.
handler | the handler |
|
virtual |
Send a raw message to the IRC server. You don't need to add message terminators.
If the server is not yet connected, the command is postponed and will be ran when ready.
raw | the raw message (without \r\n\r\n ) |
Reimplemented in irccd::test::mock_server, and irccd::test::debug_server.
|
noexcept |
Set the command character.
command_char | the command character |
void irccd::daemon::server::set_ctcp_version | ( | std::string | ctcpversion | ) |
Set the CTCP version.
ctcpversion | the version |
void irccd::daemon::server::set_nickname | ( | std::string | nickname | ) |
Set the nickname.
If the server is connected, send a nickname command to the IRC server, otherwise change it instantly.
nickname | the nickname |
|
noexcept |
Set the options flags.
flags | the flags |
|
noexcept |
Set the password.
An empty password means no password.
password | the password |
|
noexcept |
Set the ping timeout before considering a server as dead.
ping_timeout | the delay in seconds |
|
noexcept |
Set the port.
port | the port |
|
noexcept |
Set the realname.
realname | the username |
|
noexcept |
Set the number of seconds before retrying.
reconnect_delay | the number of seconds |
|
noexcept |
Set the username.
name | the username |
|
virtual |
Change the channel topic.
channel | the channel |
topic | the desired topic |
Reimplemented in irccd::test::mock_server, and irccd::test::debug_server.
|
virtual |
Wait for reconnect delay.
|
virtual |
Request for whois information.
target | the target nickname |
Reimplemented in irccd::test::mock_server, and irccd::test::debug_server.
|
protected |
Server state.