Permalink
Browse files

Net::OutOfBandPrint

  • Loading branch information...
mbasaglia committed Nov 14, 2015
1 parent 2dc850f commit 38eff6dc46c26390211e1e43ad8e7c2ee04b141b
Showing with 30 additions and 8 deletions.
  1. +21 −0 daemon/src/common/Network.h
  2. +1 −0 daemon/src/engine/qcommon/qcommon.h
  3. +8 −8 daemon/src/engine/server/sv_main.cpp
@@ -0,0 +1,21 @@
#ifndef COMMON_NETWORK_H
#define COMMON_NETWORK_H
namespace Net {
inline const std::string& OOBHeader()
{
static std::string header ="\xff\xff\xff\xff";
return header;
}
template<class... Args>
void OutOfBandPrint( netsrc_t net_socket, netadr_t adr, Str::StringRef format, Args&&... args )
{
std::string message = OOBHeader() + Str::Format( format, std::forward<Args>(args)... );
NET_SendPacket( net_socket, message.size(), message.c_str(), adr );
}
} // namespace Net
#endif // COMMON_NETWORK_H
@@ -201,6 +201,7 @@ void NET_Restart_f();
void NET_Config( bool enableNetworking );
void NET_SendPacket( netsrc_t sock, int length, const void *data, netadr_t to );
// DEPRECATED: use Net::OutOfBandPrint
void QDECL NET_OutOfBandPrint( netsrc_t net_socket, netadr_t adr, const char *format, ... ) PRINTF_LIKE(3);
void QDECL NET_OutOfBandData( netsrc_t sock, netadr_t adr, byte *format, int len );
@@ -37,6 +37,7 @@ Maryland 20850 USA.
#include "framework/CommandSystem.h"
#include "framework/CvarSystem.h"
#include "common/Network.h"
#ifdef USE_VOIP
cvar_t *sv_voip;
@@ -530,8 +531,8 @@ void SVC_Status( netadr_t from, const Cmd::Args& args )
}
}
std::string info_string = InfoMapToString( info_map );
NET_OutOfBandPrint( NS_SERVER, from, "statusResponse\n%s\n%s", info_string.c_str(), status.c_str() );
Net::OutOfBandPrint( NS_SERVER, from, "statusResponse\n%s\n%s",
InfoMapToString( info_map ), status );
}
/*
@@ -637,8 +638,7 @@ void SVC_Info( netadr_t from, const Cmd::Args& args )
info_map["gamename"] = GAMENAME_STRING; // Arnout: to be able to filter out Quake servers
std::string info_string = InfoMapToString( info_map );
NET_OutOfBandPrint( NS_SERVER, from, "infoResponse\n%s", info_string.c_str() );
Net::OutOfBandPrint( NS_SERVER, from, "infoResponse\n%s", InfoMapToString( info_map ) );
}
/*
@@ -647,7 +647,7 @@ void SVC_Info( netadr_t from, const Cmd::Args& args )
*/
void SVC_Ping( netadr_t from, const Cmd::Args& )
{
NET_OutOfBandPrint( NS_SERVER, from, "ack\n" );
Net::OutOfBandPrint( NS_SERVER, from, "ack\n" );
}
/*
@@ -787,13 +787,13 @@ class RconEnvironment: public Cmd::DefaultEnvironment {
}
void Flush() {
NET_OutOfBandPrint(NS_SERVER, from, "%s\n%s", prefix.c_str(), buffer.c_str());
Net::OutOfBandPrint(NS_SERVER, from, "%s\n%s", prefix, buffer);
buffer.clear();
}
static void PrintError(netadr_t to, const std::string& message)
{
NET_OutOfBandPrint(NS_SERVER, to, "error\n%s", message.c_str());
Net::OutOfBandPrint(NS_SERVER, to, "error\n%s", message);
}
private:
@@ -978,7 +978,7 @@ static void SVC_RconInfo( netadr_t from, const Cmd::Args& )
{"challenge", std::to_string(cvar_server_rcon_secure.Get() >= 2)},
{"timeout", std::to_string(duration_seconds)},
});
NET_OutOfBandPrint( NS_SERVER, from, "rconInfoResponse\n%s\n", rcon_info_string.c_str() );
Net::OutOfBandPrint( NS_SERVER, from, "rconInfoResponse\n%s\n", rcon_info_string );
}

0 comments on commit 38eff6d

Please sign in to comment.