This commit is contained in:
Chris Marsh
2017-07-17 09:28:54 -07:00
parent 72446df921
commit 9dc93f64b8
11 changed files with 95 additions and 199 deletions

View File

@ -5,30 +5,11 @@
#include <stdint.h>
#include <stdlib.h>
enum class OPCODE : uint32_t {
HANDSHAKE = 0,
FRAME = 1,
CLOSE = 2,
};
struct RpcMessageFrame {
OPCODE opcode;
uint32_t length;
char message[64 * 1024 - 8];
};
struct RpcConnection {
void (*onConnect)() = nullptr;
void (*onDisconnect)() = nullptr;
char appId[64];
static RpcConnection* Create(const char* applicationId);
static void Destroy(RpcConnection*&);
void Open();
void Close();
void Write(const void* data, size_t length);
RpcMessageFrame* Read();
RpcMessageFrame* GetNextFrame();
void WriteFrame(RpcMessageFrame* frame);
struct BaseConnection {
static BaseConnection* Create();
static void Destroy(BaseConnection*&);
bool Open();
bool Close();
bool Write(const void* data, size_t length);
bool Read(void* data, size_t& length);
};