forked from CPL/Simulator
cpp
This commit is contained in:
68
DroneClientCpp/NetClient.h
Normal file
68
DroneClientCpp/NetClient.h
Normal file
@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include <Windows.h>
|
||||
#include <vcclr.h>
|
||||
|
||||
#using <System.dll>
|
||||
#using <System.Net.dll>
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Net;
|
||||
using namespace System::Net::Sockets;
|
||||
|
||||
namespace DroneSimulator {
|
||||
|
||||
public ref class NetClient
|
||||
{
|
||||
public:
|
||||
ref class ConnectData
|
||||
{
|
||||
public:
|
||||
bool Connect;
|
||||
Socket^ Server;
|
||||
|
||||
ConnectData(bool connect, Socket^ server);
|
||||
};
|
||||
|
||||
ref class ReceiveData
|
||||
{
|
||||
public:
|
||||
array<Byte>^ Buffer;
|
||||
int Size;
|
||||
Socket^ Server;
|
||||
|
||||
ReceiveData(array<Byte>^ buffer, int size, Socket^ server);
|
||||
};
|
||||
|
||||
private:
|
||||
ref class ServerData
|
||||
{
|
||||
public:
|
||||
literal int size = 1024;
|
||||
array<Byte>^ buffer = gcnew array<Byte>(size);
|
||||
};
|
||||
|
||||
bool Connected;
|
||||
Socket^ ServerSocket;
|
||||
ServerData^ DataServer;
|
||||
|
||||
public:
|
||||
delegate void ClientCallback(Object^ o);
|
||||
|
||||
private:
|
||||
ClientCallback^ ConnectionCallback;
|
||||
ClientCallback^ ReceiveCallback;
|
||||
|
||||
public:
|
||||
NetClient(); // Добавлен конструктор
|
||||
|
||||
enum class ClientState { Error, Connected, Stop };
|
||||
|
||||
ClientState Connect(String^ Addr, int Port, ClientCallback^ Connection, ClientCallback^ Receive);
|
||||
void Close();
|
||||
void Send(array<Byte>^ data);
|
||||
|
||||
private:
|
||||
void ReadCallback(IAsyncResult^ ar);
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user