mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Small change
This commit is contained in:
parent
8d33d01cd6
commit
ad65ff1f63
@ -33,31 +33,6 @@ bool CNetCon::Init(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// purpose: connect to specified address and port
|
|
||||||
// Input : svInAdr -
|
|
||||||
// svInPort -
|
|
||||||
// Output : true if connection succeeds, false otherwise
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
bool CNetCon::Connect(std::string svInAdr, std::string svInPort)
|
|
||||||
{
|
|
||||||
if (svInAdr.size() > 0 && svInPort.size() > 0)
|
|
||||||
{
|
|
||||||
// Default is [127.0.0.1]:37015
|
|
||||||
m_pNetAdr2->SetIPAndPort(svInAdr, svInPort);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_pSocket->ConnectSocket(*m_pNetAdr2, true) == SOCKET_ERROR)
|
|
||||||
{
|
|
||||||
std::cerr << "Failed to connect. Error: 'SOCKET_ERROR'. Verify IP and PORT." << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
std::cout << "Connected to: " << m_pNetAdr2->GetIPAndPort() << std::endl;
|
|
||||||
|
|
||||||
m_abConnEstablished = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// purpose: WSA and NETCON systems shutdown
|
// purpose: WSA and NETCON systems shutdown
|
||||||
// Output : true on success, false otherwise
|
// Output : true on success, false otherwise
|
||||||
@ -114,26 +89,6 @@ void CNetCon::TermSetup(void)
|
|||||||
SetConsoleScreenBufferInfoEx(hOutput, &sbInfoEx);
|
SetConsoleScreenBufferInfoEx(hOutput, &sbInfoEx);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// purpose: client's main processing loop
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void CNetCon::RunFrame(void)
|
|
||||||
{
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
if (m_abConnEstablished)
|
|
||||||
{
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
||||||
this->Recv();
|
|
||||||
}
|
|
||||||
else if (m_abPromptConnect)
|
|
||||||
{
|
|
||||||
std::cout << "Enter <IP> <PORT>: ";
|
|
||||||
m_abPromptConnect = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// purpose: gets input IP and port for initialization
|
// purpose: gets input IP and port for initialization
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -169,7 +124,6 @@ void CNetCon::UserInput(void)
|
|||||||
}
|
}
|
||||||
else // Initialize as [127.0.0.1]:37015.
|
else // Initialize as [127.0.0.1]:37015.
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!this->Connect("", ""))
|
if (!this->Connect("", ""))
|
||||||
{
|
{
|
||||||
m_abPromptConnect = true;
|
m_abPromptConnect = true;
|
||||||
@ -180,6 +134,60 @@ void CNetCon::UserInput(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// purpose: client's main processing loop
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CNetCon::RunFrame(void)
|
||||||
|
{
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
if (m_abConnEstablished)
|
||||||
|
{
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
|
this->Recv();
|
||||||
|
}
|
||||||
|
else if (m_abPromptConnect)
|
||||||
|
{
|
||||||
|
std::cout << "Enter <IP> <PORT>: ";
|
||||||
|
m_abPromptConnect = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// purpose: checks if application should be terminated
|
||||||
|
// Output : true for termination, false otherwise
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool CNetCon::ShouldQuit(void)
|
||||||
|
{
|
||||||
|
return this->m_bQuitApplication;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// purpose: connect to specified address and port
|
||||||
|
// Input : svInAdr -
|
||||||
|
// svInPort -
|
||||||
|
// Output : true if connection succeeds, false otherwise
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool CNetCon::Connect(std::string svInAdr, std::string svInPort)
|
||||||
|
{
|
||||||
|
if (svInAdr.size() > 0 && svInPort.size() > 0)
|
||||||
|
{
|
||||||
|
// Default is [127.0.0.1]:37015
|
||||||
|
m_pNetAdr2->SetIPAndPort(svInAdr, svInPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_pSocket->ConnectSocket(*m_pNetAdr2, true) == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to connect. Error: 'SOCKET_ERROR'. Verify IP and PORT." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
std::cout << "Connected to: " << m_pNetAdr2->GetIPAndPort() << std::endl;
|
||||||
|
|
||||||
|
m_abConnEstablished = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// purpose: send message
|
// purpose: send message
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -259,7 +267,7 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!pNetCon->m_bQuitApplication)
|
while (!pNetCon->ShouldQuit())
|
||||||
{
|
{
|
||||||
pNetCon->UserInput();
|
pNetCon->UserInput();
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,13 @@ public:
|
|||||||
void UserInput(void);
|
void UserInput(void);
|
||||||
|
|
||||||
void RunFrame(void);
|
void RunFrame(void);
|
||||||
|
bool ShouldQuit(void);
|
||||||
|
|
||||||
bool Connect(std::string svInAdr, std::string svInPort);
|
bool Connect(std::string svInAdr, std::string svInPort);
|
||||||
|
|
||||||
void Send(std::string svMessage);
|
void Send(std::string svMessage);
|
||||||
void Recv(void);
|
void Recv(void);
|
||||||
|
|
||||||
|
private:
|
||||||
CNetAdr2* m_pNetAdr2 = new CNetAdr2("localhost", "37015");
|
CNetAdr2* m_pNetAdr2 = new CNetAdr2("localhost", "37015");
|
||||||
CSocketCreator* m_pSocket = new CSocketCreator();
|
CSocketCreator* m_pSocket = new CSocketCreator();
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Microsoft Visual C++ generated resource script.
|
// Microsoft Visual C++ generated resource script.
|
||||||
//
|
//
|
||||||
#define USE_RES
|
#define USE_RES
|
||||||
#define RELEASE
|
//#define RELEASE
|
||||||
#ifdef USE_RES
|
#ifdef USE_RES
|
||||||
#include "sdklauncher/sdklauncher_res.h"
|
#include "sdklauncher/sdklauncher_res.h"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user