Example #1
0
/**
 * @brief Handles a connectionless message from a client
 * @sa NET_OOB_Printf
 * @param[out] stream The stream to write to
 * @param msg The message buffer to read the connectionless data from
 */
static void SV_ConnectionlessPacket (struct net_stream *stream, dbuffer *msg)
{
	const char *c;
	char s[512];
	char buf[256];

	NET_ReadStringLine(msg, s, sizeof(s));

	Cmd_TokenizeString(s, false);

	c = Cmd_Argv(0);
	Com_DPrintf(DEBUG_SERVER, "Packet : %s\n", c);

	if (Q_streq(c, "teaminfo"))
		SVC_TeamInfo(stream);
	else if (Q_streq(c, "info"))
		SVC_Info(stream);
	else if (Q_streq(c, "status"))
		SVC_Status(stream);
	else if (Q_streq(c, "connect"))
		SVC_DirectConnect(stream);
	else if (Q_streq(c, "rcon"))
		SVC_RemoteCommand(stream);
	else
		Com_Printf("Bad connectionless packet from %s:\n%s\n", NET_StreamPeerToName(stream, buf, sizeof(buf), true), s);
}
Example #2
0
/**
 * @brief Handles a connectionless message from a client
 * @sa NET_OOB_Printf
 * @param[out] stream The stream to write to
 * @param msg The message buffer to read the connectionless data from
 */
static void SV_ConnectionlessPacket (struct net_stream* stream, dbuffer* msg)
{
    char s[512];

    NET_ReadStringLine(msg, s, sizeof(s));
    Cmd_TokenizeString(s, false, false);

    const char* c = Cmd_Argv(0);
    Com_DPrintf(DEBUG_SERVER, "Packet : %s\n", c);

    if (Q_streq(c, SV_CMD_TEAMINFO)) {
        SVC_TeamInfo(stream);
    } else if (Q_streq(c, SV_CMD_INFO)) {
        SVC_Info(stream);
    } else if (Q_streq(c, SV_CMD_STATUS)) {
        SVC_Status(stream);
    } else if (Q_streq(c, SV_CMD_CONNECT)) {
        SVC_DirectConnect(stream);
    } else if (Q_streq(c, SV_CMD_RCON)) {
        SVC_RemoteCommand(stream);
    } else {
        char buf[256];
        Com_Printf("Bad connectionless packet from %s:\n%s\n", NET_StreamPeerToName(stream, buf, sizeof(buf), true), s);
    }
}