sm-ext-AsyncSocket/context.h
2015-05-21 13:29:14 -04:00

40 lines
726 B
C++

#ifndef ASYNC_SOCKET_CONTEXT_H
#define ASYNC_SOCKET_CONTEXT_H
#include <stdlib.h>
#include <uv.h>
#include "smsdk_ext.h"
class AsyncSocketContext {
public:
IPluginContext* pContext;
Handle_t hndl;
char* host;
int port;
IChangeableForward *connectCallback;
IChangeableForward *errorCallback;
IChangeableForward *dataCallback;
uv_getaddrinfo_t resolver;
uv_connect_t* connect_req;
uv_tcp_t* socket;
AsyncSocketContext(IPluginContext* plugin);
~AsyncSocketContext();
void Connected();
void OnError(int error);
void OnData(char* data, ssize_t size);
bool SetConnectCallback(funcid_t function);
bool SetErrorCallback(funcid_t function);
bool SetDataCallback(funcid_t function);
};
#endif