#pragma once
#include "ModuleHook.h"
namespace NosSmoothCore
{
public delegate bool NetworkCallback(System::String^ packet);
typedef bool(__stdcall* PacketCallback)(const char* packet);
class NetworkUnmanaged
{
public:
void Setup(NosSmoothCore::ModuleHook moduleHook);
///
/// Send the given packet to the server.
///
/// The packed to send.
void SendPacket(const char * packet);
///
/// Receive the given packet on the client.
///
/// The packet to receive.
void ReceivePacket(const char * packet);
///
/// Sets the receive callback delegate to be called when packet is received.
///
///
void SetReceiveCallback(PacketCallback callback);
///
/// Sets the send callback delegate to be called when the packet is sent.
///
///
void SetSendCallback(PacketCallback callback);
///
/// Resets all the function hooks.
///
void ResetHooks();
bool ExecuteSendCallback(const char *packet);
bool ExecuteReceiveCallback(const char *packet);
static NetworkUnmanaged* GetInstance()
{
static NetworkUnmanaged instance;
return reinterpret_cast(&instance);
}
private:
unsigned int _callerObject;
unsigned int _receivePacketAddress;
unsigned int _sendPacketAddress;
PacketCallback _sendCallback;
PacketCallback _receiveCallback;
};
}