Code/ServerApp/Source/ServerNetworking.cpp
//=================================================================================================
// Establish connection with Remote Client
// Makes sure that Server/Client are compatible
//=================================================================================================
Establish connection with Remote Client
Makes sure that Server/Client are compatible
Establish connection with Remote Client Makes sure that Server / Client are compatible
bool Communications_InitializeClient(SOCKET Socket, ClientRemote* pClient)
{
	NetImgui::Internal::CmdVersion cmdVersionSend;
	NetImgui::Internal::CmdVersion cmdVersionRcv;
	strcpy_s(cmdVersionSend.mClientName,"Server");
	int resultSend	= send(Socket, reinterpret_cast<const char*>(&cmdVersionSend), static_cast<int>(cmdVersionSend.mHeader.mSize), 0);
	int resultRcv	= recv(Socket, reinterpret_cast<char*>(&cmdVersionRcv), sizeof(cmdVersionRcv), MSG_WAITALL);
	if(	resultSend > 0 && resultRcv > 0 && 
		cmdVersionRcv.mHeader.mType == NetImgui::Internal::CmdHeader::eCommands::Version && 
		cmdVersionRcv.mVersion == NetImgui::Internal::CmdVersion::eVersion::_Current )
	{		
		ClientConfig clientConfig;
		if( ClientConfig::GetConfigByID(pClient->mClientConfigID, clientConfig) )
			sprintf_s(pClient->mInfoName, "%s (%s)", clientConfig.ClientName, cmdVersionRcv.mClientName);
		else
			sprintf_s(pClient->mInfoName, "%s", cmdVersionRcv.mClientName);
		strcpy_s(pClient->mInfoImguiVerName,	cmdVersionRcv.mImguiVerName);
		strcpy_s(pClient->mInfoNetImguiVerName, cmdVersionRcv.mNetImguiVerName);
		pClient->mInfoImguiVerID	= cmdVersionRcv.mImguiVerID;
		pClient->mInfoNetImguiVerID = cmdVersionRcv.mNetImguiVerID;
		return true;
	}
	return false;
}
bool Communications_InitializeClient ( SOCKET Socket , ClientRemote * pClient ) { NetImgui :: Internal :: CmdVersion cmdVersionSend ; NetImgui :: Internal :: CmdVersion cmdVersionRcv ; strcpy_s ( cmdVersionSend . mClientName , " " ) ; int resultSend = send ( Socket , reinterpret_cast < const char * > ( & cmdVersionSend ) , static_cast < int > ( cmdVersionSend . mHeader . mSize ) , 0 ) ; int resultRcv = recv ( Socket , reinterpret_cast < char * > ( & cmdVersionRcv ) , sizeof ( cmdVersionRcv ) , MSG_WAITALL ) ; if ( resultSend > 0 && resultRcv > 0 && cmdVersionRcv . mHeader . mType == NetImgui :: Internal :: CmdHeader :: eCommands :: Version && cmdVersionRcv . mVersion == NetImgui :: Internal :: CmdVersion :: eVersion :: _Current ) { ClientConfig clientConfig ; if ( ClientConfig :: GetConfigByID ( pClient -> mClientConfigID , clientConfig ) ) sprintf_s ( pClient -> mInfoName , " " , clientConfig . ClientName , cmdVersionRcv . mClientName ) ; else sprintf_s ( pClient -> mInfoName , " " , cmdVersionRcv . mClientName ) ; strcpy_s ( pClient -> mInfoImguiVerName , cmdVersionRcv . mImguiVerName ) ; strcpy_s ( pClient -> mInfoNetImguiVerName , cmdVersionRcv . mNetImguiVerName ) ; pClient -> mInfoImguiVerID = cmdVersionRcv . mImguiVerID ; pClient -> mInfoNetImguiVerID = cmdVersionRcv . mNetImguiVerID ; return true ; } return false ; }
Establish connection with Remote Client
Makes sure that Server/Client are compatible
Establish connection with Remote Client Makes sure that Server / Client are compatible