AuroraRuntime/Source/IO/Net/AuNetResolver.NT.hpp

54 lines
1.4 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuNetResolver.NT.hpp
Date: 2022-8-17
Author: Reece
***/
#pragma once
#include "AuNetSocketOverlappedOperation.hpp"
#include "AuNetSocket.hpp"
namespace Aurora::IO::Net
{
struct Socket;
struct NetResolver :
SocketOverlappedOperation,
IResolver,
AuEnableSharedFromThis<NetResolver>
{
NetResolver(const AuSPtr<INetWorker> &pWorker);
NetResolver(const AuSPtr<INetWorker> &pWorker,
const AuSPtr<AuAsync::PromiseCallback<AuList<IPAddress>, NetError>> &pCompletion);
~NetResolver();
bool bA {};
bool bAAAA {};
AuString hostname;
bool Start();
void SetCompletion(const AuSPtr<AuAsync::PromiseCallback<AuList<IPAddress>, NetError>> &callback);
void OnOverlappedComplete() override;
void OnOverlappedFailure(const NetError &error) override;
bool HasFinished() override;
void Cancel() override;
const NetError &GetError() override;
bool Unpack();
private:
AuSPtr<INetWorker> pWorker_;
AuList<IPAddress> processedIps_;
AuSPtr<AuAsync::PromiseCallback<AuList<IPAddress>, NetError>> pCompletion_;
bool bHasCompleted_ {};
bool bForceError_ {};
PADDRINFOEXW resultHandle_ {};
NetError error_;
HANDLE hName_ { NULL };
};
}