Send and receive messages
Also correctly respond to PING with the id, escape some XML content, but not always
This commit is contained in:
+30
-2
@@ -44,6 +44,10 @@ public:
|
||||
* Return the channel with this name, create it if it does not yet exist
|
||||
*/
|
||||
IrcChannel* get_channel(const std::string& name);
|
||||
/**
|
||||
* Return our own nick
|
||||
*/
|
||||
std::string get_own_nick() const;
|
||||
/**
|
||||
* Serialize the given message into a line, and send that into the socket
|
||||
* (actually, into our out_buf and signal the poller that we want to wach
|
||||
@@ -53,7 +57,7 @@ public:
|
||||
/**
|
||||
* Send the PONG irc command
|
||||
*/
|
||||
void send_pong_command();
|
||||
void send_pong_command(const IrcMessage& message);
|
||||
/**
|
||||
* Send the USER irc command
|
||||
*/
|
||||
@@ -66,6 +70,11 @@ public:
|
||||
* Send the JOIN irc command
|
||||
*/
|
||||
void send_join_command(const std::string& chan_name);
|
||||
/**
|
||||
* Send a PRIVMSG command for a channel
|
||||
* Return true if the message was actually sent
|
||||
*/
|
||||
bool send_channel_message(const std::string& chan_name, const std::string& body);
|
||||
/**
|
||||
* Forward the server message received from IRC to the XMPP component
|
||||
*/
|
||||
@@ -80,6 +89,10 @@ public:
|
||||
* of user comes after so we do not send the self-presence over XMPP yet.
|
||||
*/
|
||||
void on_self_channel_join(const IrcMessage& message);
|
||||
/**
|
||||
* When a channel message is received
|
||||
*/
|
||||
void on_channel_message(const IrcMessage& message);
|
||||
/**
|
||||
* Save the topic in the IrcChannel
|
||||
*/
|
||||
@@ -89,6 +102,10 @@ public:
|
||||
* received etc), send the self presence and topic to the XMPP user.
|
||||
*/
|
||||
void on_channel_completely_joined(const IrcMessage& message);
|
||||
/**
|
||||
* When a message 001 is received, join the rooms we wanted to join, and set our actual nickname
|
||||
*/
|
||||
void on_welcome_message(const IrcMessage& message);
|
||||
|
||||
private:
|
||||
/**
|
||||
@@ -99,15 +116,26 @@ private:
|
||||
* The user name used in the USER irc command
|
||||
*/
|
||||
const std::string username;
|
||||
/**
|
||||
* Our current nickname on the server
|
||||
*/
|
||||
std::string current_nick;
|
||||
/**
|
||||
* Raw pointer because the bridge owns us.
|
||||
*/
|
||||
Bridge* bridge;
|
||||
|
||||
/**
|
||||
* The list of joined channels, indexed by name
|
||||
*/
|
||||
std::unordered_map<std::string, std::unique_ptr<IrcChannel>> channels;
|
||||
/**
|
||||
* A list of chan we want to join, but we need a response 001 from
|
||||
* the server before sending the actual JOIN commands. So we just keep the
|
||||
* channel names in a list, and send the JOIN commands for each of them
|
||||
* whenever the WELCOME message is received.
|
||||
*/
|
||||
std::vector<std::string> channels_to_join;
|
||||
bool welcomed;
|
||||
|
||||
IrcClient(const IrcClient&) = delete;
|
||||
IrcClient(IrcClient&&) = delete;
|
||||
|
||||
Reference in New Issue
Block a user