-
Notifications
You must be signed in to change notification settings - Fork 1
/
MsgIRC.hpp
51 lines (41 loc) · 1.17 KB
/
MsgIRC.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef _MESSAGESIRC_
#define _MESSAGESIRC_
#include "UserIRC.hpp"
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <sstream>
using namespace std;
struct UserIRC;
struct PayloadIRC
{
string command;
list<string> params;
string prefix;
string trailer;
string CTCP_Data;
PayloadIRC(){}
PayloadIRC(const string& prefix) : prefix(prefix) {}
PayloadIRC(const PayloadIRC& other): command(other.command), params(other.params),prefix(other.prefix), trailer(other.trailer){}
bool empty();
};
struct MsgIRC
{
UserIRC* sender;
UserIRC* receiver;
PayloadIRC payload;
MsgIRC(UserIRC* _receiver, const PayloadIRC& _payload):
sender(0), receiver(_receiver), payload(_payload){}
MsgIRC(UserIRC* _sender,UserIRC* _receiver, const PayloadIRC& _payload):
sender(_sender), receiver(_receiver), payload(_payload){}
MsgIRC();
~MsgIRC(){}
//add the function to call payload later
};
//send the message and remove it from the writelist (return send)
size_t sendMsg(fd_set &availableWSockets, MsgIRC& msg);
//read and parse the msg
size_t receiveMsg(UserIRC* user, fd_set &availableSockets, list<MsgIRC>& msg);
PayloadIRC parsingToPayload(char* buffer);
#endif