-
Notifications
You must be signed in to change notification settings - Fork 1
/
sam.h
70 lines (55 loc) · 1.51 KB
/
sam.h
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef SAM_H
#define SAM_H
typedef enum{
stream, datagram, raw
}SAMstyle;
class sam
{
private:
void connect(const char * host, int port);
protected:
int m_sock, m_port;
bool error;
char * m_host=0, * pubkey=0, * privkey=0;
//TODO: From Friend List get count of incoming/ outcoming
int c_incoming, c_outcoming;
int c_m_incoming, c_m_outcoming;
int * incoming=0, * outcoming=0;
protected:
bool getStatus(int socket);
public:
bool accept(const char * nickname="Isis");
bool connect(const char * destination,const char * nickname="Isis");
public: // sesions
void DeleteSession(const char * nickname);
void CreateSession(const char * nickname="Isis", SAMstyle s = stream );
void WhileSession(void);
public: // keys
void loadKeys(const char * pubkey, const char * privkey);
void generateDestination(void);
char * getPubkey(void);
char * getPrivkey(void);
//last connectings
public:
int getIncoming(void){
return c_incoming;
}
int getOutcoming(void){
return c_outcoming;
}
public: // errors/is sam
bool isSam(const char * host, int port);
bool isSam(int sock, bool closeConnect=true);
bool getError(void);
int& operator[] (int x){
if(c_incoming > x && incoming)
return incoming[x];
this->error=true;
throw "Overflow of SAM::operator[]";
return incoming[0];
}
public: // construct/destruct
explicit sam(const char * host, int port);
~sam();
};
#endif // SAM_H