Erwan
- Crude networking functions: + Basic message works on Windows + Compiles on PSP but doesn't work yet + Nothing done for Linux -> TODO!
This commit is contained in:
43
JGE/include/JNetwork.h
Normal file
43
JGE/include/JNetwork.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef _JNETWORK_H_
|
||||
#define _JNETWORK_H_
|
||||
|
||||
#ifdef WIN32
|
||||
#elif defined (LINUX)
|
||||
#else
|
||||
#endif
|
||||
|
||||
#include "JGE.h"
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
class JNetwork{
|
||||
private:
|
||||
static JNetwork * mInstance;
|
||||
static int connected_to_ap;
|
||||
public:
|
||||
JNetwork();
|
||||
static JNetwork * GetInstance();
|
||||
static void EndInstance();
|
||||
static string serverIP;
|
||||
int receive(char * buffer, int length);
|
||||
int send(char * buffer, int length);
|
||||
int connect(string serverIP = "");
|
||||
static int isConnected();
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
static int net_thread(LPVOID param);
|
||||
#else
|
||||
static int net_thread(SceSize args, void *argp);
|
||||
static int connect_to_apctl(int config);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
static DWORD netthread;
|
||||
#else
|
||||
static int netthread;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
30
JGE/include/JSocket.h
Normal file
30
JGE/include/JSocket.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef _JSOCKET_H_
|
||||
#define _JSOCKET_H_
|
||||
|
||||
#include <queue>
|
||||
using namespace std;
|
||||
|
||||
//TODO config ?
|
||||
#define SERVER_PORT 20666
|
||||
|
||||
class JSocket{
|
||||
public:
|
||||
queue<char> received_data;
|
||||
queue<char> tosend_data;
|
||||
static JSocket * mInstance;
|
||||
int start_server(const char *szIpAddr);
|
||||
int start_client(const char *szIpAddr);
|
||||
|
||||
JSocket();
|
||||
~JSocket();
|
||||
static int connected;
|
||||
private:
|
||||
void init();
|
||||
void readWrite(int sock);
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#else
|
||||
int make_socket(uint16_t port);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user