You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

70 lines
1.4 KiB

#ifndef __BETACORE_CLIENT_HPP__
#define __BETACORE_CLIENT_HPP__
#include <string>
#include <iostream>
#include <functional>
#include <sstream>
#include <vector>
#include <thread>
#include <map>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <netdb.h>
#include <netinet/in.h>
#include <unistd.h>
#include "common.hpp"
namespace betacore
{
class Client
{
private:
bool _online = false;
bool _running = false;
char key = 'Z';
int _port;
std::string _url;
MODE _mode;
int _client_socket;
std::function<void(SHAPE &S, MODE &M)> _update;
struct sockaddr_in _server_address;
struct hostent *_server;
std::map<std::string, std::string> lookup;
std::vector<std::string> explode(std::string &message);
std::string encode(const SHAPE &shape);
std::string crypt(const std::string &shape);
std::string raw(const SHAPE &shape);
SHAPE parse(const std::string &message);
SHAPE decode(const std::string &message);
/**
* Function for Thread for getting information from server
*/
void listener();
/**
* Function for Thread for sending to server
*/
void sender();
void start();
void stop();
public:
Client(
MODE mode,
int port,
std::string url,
std::function<void(SHAPE &S, MODE &M)> &update);
~Client();
void kill();
bool running();
void send(bool encrypt, SHAPE shape);
};
} // namespace betacore
#endif