Ejemplo n.º 1
0
/***********************************************************************************************************************
Function: SrvThreadProc
Description:
Called By:
Input:
Output:
Return:
Others:
************************************************************************************************************************/
tProcType_t CNetServer::SrvThreadProc(tProcPara_t Param)
{
    if (Param)
    {
        CNetServer *pSlef = (CNetServer *)Param;
        pSlef->SrvThreadBody();
    }

    return NULL;
}
Ejemplo n.º 2
0
/***********************************************************************************************************************
Function: QTaskProc
Description:
Called By:
Input:
Output:
Return:
Others:
************************************************************************************************************************/
tProcType_t CNetServer::QTaskProc(tProcPara_t Param)
{
    if (Param)
    {
        CNetServer *pSlef = (CNetServer *)Param;
        pSlef->QTaskBody();
    }

    return NULL;
}
Ejemplo n.º 3
0
/***********************************************************************************************************************
Function: TaskCb
Description:
Called By:
Input:
Output:
Return:
Others:
************************************************************************************************************************/
S32 CNetServer::TaskCb(Socket_t sHandle, Void *Obj)
{
    if (Obj)
    {
        CNetServer *pSelf = (CNetServer *)Obj;
        pSelf->DoReq(sHandle);
    }

    return MW_SUCC;
}
Ejemplo n.º 4
0
int _tmain(int argc, _TCHAR* argv[])
{
	CNetServer netSvrApp;
	netSvrApp.Begin(4999);

	extern HANDLE g_hCloseApp;
	g_hCloseApp = CreateEvent(NULL, TRUE, FALSE, NULL);
	ResetEvent( g_hCloseApp );
	WaitForSingleObject( g_hCloseApp, INFINITE);
	CloseHandle( g_hCloseApp );
}
Ejemplo n.º 5
0
CJsonNode CExecAndParseStructuredOutput::ExecOn(CNetServer server)
{
    m_NSOutput = server.ExecWithRetry(m_Cmd).response;
    m_Ch = m_NSOutput.c_str();

    return ParseObject(true);
}
Ejemplo n.º 6
0
//int _tmain(int argc, _TCHAR* argv[])
int win32_main()
{
	//return TestAvi();

	DEBUG_INFO("Media server start...\n");
	SysInit();	

	CNetServer Srv;
	Srv.SetTask(10, 1024 *1024);
	Srv.Start("55555:9527:9088:12345:65432");

	while(1){ sleep(1); };

	SysUnInit();

	return MW_SUCC;
}
Ejemplo n.º 7
0
CJsonNode g_LegacyStatToJson(CNetServer server, bool verbose)
{
    const string stat_cmd(verbose ? "STAT ALL" : "STAT");

    CNetServerMultilineCmdOutput output(server.ExecWithRetry(stat_cmd, true));

    CJsonNode stat_info(CJsonNode::NewObjectNode());
    CJsonNode jobs_by_status(CJsonNode::NewObjectNode());;
    stat_info.SetByKey("JobsByStatus", jobs_by_status);
    CJsonNode section_entries;

    string line;
    CTempString key, value;

    while (output.ReadLine(line)) {
        if (line.empty() || isspace(line[0]))
            continue;

        if (line[0] == '[') {
            size_t section_name_len = line.length();
            while (--section_name_len > 0 &&
                    (line[section_name_len] == ':' ||
                    line[section_name_len] == ']' ||
                    isspace(line[section_name_len])))
                ;
            line.erase(0, 1);
            line.resize(section_name_len);
            stat_info.SetByKey(line,
                    section_entries = CJsonNode::NewArrayNode());
        }
        else if (section_entries) {
            section_entries.AppendString(line);
        }
        else if (NStr::SplitInTwo(line, ":", key, value)) {
            value = NStr::TruncateSpaces_Unsafe(value, NStr::eTrunc_Begin);
            if (CNetScheduleAPI::StringToStatus(key) !=
                    CNetScheduleAPI::eJobNotFound)
                jobs_by_status.SetInteger(key, NStr::StringToInt8(value));
            else {
                if (key == "Executable path" &&
                        g_FixMisplacedPID(stat_info, value, "PID")) {
                    if (!stat_info.HasKey("Version"))
                        stat_info.SetString("Version", "Unknown");

                    if (!stat_info.HasKey("Build date"))
                        stat_info.SetString("Build date", "Unknown");
                }
                stat_info.SetByKey(key, CJsonNode::GuessType(value));
            }
        }
    }

    return stat_info;
}
Ejemplo n.º 8
0
CJsonNode g_GenericStatToJson(CNetServer server,
        ENetScheduleStatTopic topic, bool verbose)
{
    string stat_cmd(s_StatTopics[topic].command);
    CTempString prefix(s_StatTopics[topic].record_prefix);
    CTempString entity_name(s_StatTopics[topic].entity_name);

    if (verbose)
        stat_cmd.append(" VERBOSE");

    CNetServerMultilineCmdOutput output(server.ExecWithRetry(stat_cmd, true));

    CJsonNode entities(CJsonNode::NewArrayNode());
    CJsonNode entity_info;
    CJsonNode array_value;

    string line;

    while (output.ReadLine(line)) {
        if (NStr::StartsWith(line, prefix)) {
            if (entity_info)
                entities.Append(entity_info);
            entity_info = CJsonNode::NewObjectNode();
            entity_info.SetString(entity_name, UnquoteIfQuoted(
                    CTempString(line.data() + prefix.length(),
                    line.length() - prefix.length())));
        } else if (entity_info && NStr::StartsWith(line, "  ")) {
            if (NStr::StartsWith(line, "    ") && array_value) {
                array_value.AppendString(UnquoteIfQuoted(
                        NStr::TruncateSpaces(line, NStr::eTrunc_Begin)));
            } else {
                if (array_value)
                    array_value = NULL;
                CTempString key, value;
                NStr::SplitInTwo(line, ":", key, value);
                NormalizeStatKeyName(key);
                string key_norm(key);
                value = NStr::TruncateSpaces_Unsafe(value, NStr::eTrunc_Begin);
                if (value.empty())
                    entity_info.SetByKey(key_norm, array_value =
                            CJsonNode::NewArrayNode());
                else
                    entity_info.SetByKey(key_norm, CJsonNode::GuessType(value));
            }
        }
    }
    if (entity_info)
        entities.Append(entity_info);

    return entities;
}
Ejemplo n.º 9
0
CJsonNode g_LegacyStatToJson(CNetServer server, bool verbose)
{
    const string stat_cmd(verbose ? "STAT ALL" : "STAT");

    CNetServerMultilineCmdOutput output(server.ExecWithRetry(stat_cmd));

    CJsonNode stat_info(CJsonNode::NewObjectNode());
    CJsonNode jobs_by_status(CJsonNode::NewObjectNode());;
    stat_info.SetNode("JobsByStatus", jobs_by_status);
    CJsonNode section_entries;

    string line;
    CTempString key, value;

    while (output.ReadLine(line)) {
        if (line.empty() || isspace(line[0]))
            continue;

        if (line[0] == '[') {
            size_t section_name_len = line.length();
            while (--section_name_len > 0 &&
                    (line[section_name_len] == ':' ||
                    line[section_name_len] == ']' ||
                    isspace(line[section_name_len])))
                ;
            line.erase(0, 1);
            line.resize(section_name_len);
            stat_info.SetNode(line,
                    section_entries = CJsonNode::NewArrayNode());
        } else if (section_entries)
            section_entries.PushString(line);
        else if (NStr::SplitInTwo(line, ":", key, value)) {
            value = NStr::TruncateSpaces(value, NStr::eTrunc_Begin);
            if (CNetScheduleAPI::StringToStatus(key) ==
                    CNetScheduleAPI::eJobNotFound)
                stat_info.SetString(key, value);
            else
                jobs_by_status.SetNumber(key, NStr::StringToInt8(value));
        }
    }

    return stat_info;
}
Ejemplo n.º 10
0
CJsonNode CExecAndParseStructuredOutput::ExecOn(CNetServer server)
{
    CNetScheduleStructuredOutputParser parser;

    return parser.ParseObject(server.ExecWithRetry(m_Cmd, false).response);
}