Beispiel #1
0
/**
 * @brief
 */
static void Ms_ParseMessage(struct sockaddr_in *from, char *data) {
	char *cmd = data;
	char *line = data;

	while (*line && *line != '\n') {
		line++;
	}

	*(line++) = '\0';
	cmd += 4;

	if (!g_ascii_strncasecmp(cmd, "ping", 4)) {
		Ms_AddServer(from);
	} else if (!g_ascii_strncasecmp(cmd, "heartbeat", 9) || !g_ascii_strncasecmp(cmd, "print", 5)) {
		Ms_Heartbeat(from);
	} else if (!g_ascii_strncasecmp(cmd, "ack", 3)) {
		Ms_Ack(from);
	} else if (!g_ascii_strncasecmp(cmd, "shutdown", 8)) {
		Ms_RemoveServer(from);
	} else if (!g_ascii_strncasecmp(cmd, "getservers", 10) || !g_ascii_strncasecmp(cmd, "y", 1)) {
		Ms_GetServers(from);
	} else {
		Com_Warn("Unknown command from %s: '%s'", atos(from), cmd);
	}
}
Beispiel #2
0
/*
 * @brief
 */
static void Ms_ParseMessage(struct sockaddr_in *from, char *data) {
	char *cmd = data;
	char *line = data;

	while (*line && *line != '\n')
		line++;

	*(line++) = '\0';
	cmd += 4;

	if (!strncasecmp(cmd, "ping", 4)) {
		Ms_AddServer(from);
	} else if (!strncasecmp(cmd, "heartbeat", 9) || !strncasecmp(cmd, "print", 5)) {
		Ms_Heartbeat(from);
	} else if (!strncasecmp(cmd, "ack", 3)) {
		Ms_Ack(from);
	} else if (!strncasecmp(cmd, "shutdown", 8)) {
		Ms_RemoveServer(from, NULL);
	} else if (!strncasecmp(cmd, "getservers", 10) || !strncasecmp(cmd, "y", 1)) {
		Ms_SendServersList(from);
	} else {
		Com_Print("Unknown command from %s: '%s'", inet_ntoa(from->sin_addr), cmd);
	}
}