summaryrefslogtreecommitdiff
path: root/protocols/WhatsApp/src/WASocketConnection.h
blob: 53d16fd4193abb39d58fa6321b8030ad81eac4ce (plain)
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
#if !defined(WASOCKETCONNECTION_H)
#define WASOCKETCONNECTION_H

#include "common.h"
#include "WhatsAPI++/ISocketConnection.h"
#include <iostream>
#include "WhatsAPI++/WAException.h"
#include "WhatsAPI++/WALogin.h"
#include <windows.h>

class WASocketConnection : public ISocketConnection
{
public:
   static HANDLE hNetlibUser;

private:
	int readSize;
	int maxBufRead;
	bool connected;

   HANDLE hConn;

public:
	WASocketConnection(const std::string& dir, int port) throw (WAException);
	void write(int i);
	unsigned char read();
	void flush();
	void write(const std::vector<unsigned char>& b, int length);
	void write(const std::vector<unsigned char>& bytes, int offset, int length);
	int read(std::vector<unsigned char>& b, int off, int length);
	void makeNonBlock();
	int waitForRead();
	void forceShutdown();

	virtual ~WASocketConnection();
	static void initNetwork(HANDLE hNetlibUser) throw (WAException);
	static void quitNetwork();
};

#endif // WASOCKETCONNECTION_H