void CNetUpgrade::OnPeripheral() { ProcessSend(DH_UPGRADE_PERIPHERAL_TYPE); }
void CNetUpgrade::OnGeoInfo() { ProcessSend(DH_UPGRADE_GEOINFO_TYPE); }
void CNetUpgrade::OnBiosandboot() { ProcessSend(); }
void CNetUpgrade::OnSendweb() { ProcessSend(); }
void CNetUpgrade::OnSendbios() { ProcessSend(); }
bool InboundHTTP4RTMP::SignalInputData(IOBuffer &buffer) { //1. Get the HTTP far protool and test to see if it has ContentLength InboundHTTPProtocol *pHTTP = (InboundHTTPProtocol *) _pFarProtocol; if (pHTTP == NULL || pHTTP->GetContentLength() == 0) { FATAL("Invalid HTTP request"); return false; } //2. Test it and see if all the data was transfered if (!pHTTP->TransferCompleted()) { return true; } //3. Get the HTTP request Variant request = pHTTP->GetHeaders(); //4. Is this a keep-alive? pHTTP->SetDisconnectAfterTransfer( request[HTTP_HEADERS][HTTP_HEADERS_CONNECTION] != HTTP_HEADERS_CONNECTION_KEEP_ALIVE); DeleteNearProtocol(false); //4. Get the URL string url = request[HTTP_FIRST_LINE][HTTP_URL]; //5. split it in meaningful parts vector<string> parts; split(url, "/", parts); if (parts.size() < 2) { FATAL("Invalid request:\n%s", STR(request.ToString())); return false; } //7. Do the dammage bool result; if (parts[1] == "fcs") { result = ProcessFcs(parts); buffer.Ignore(pHTTP->GetContentLength()); } else if (parts[1] == "open") { result = ProcessOpen(parts); buffer.Ignore(pHTTP->GetContentLength()); } else if (parts[1] == "idle") { result = ProcessIdle(parts); buffer.Ignore(pHTTP->GetContentLength()); } else if (parts[1] == "send") { if (GETAVAILABLEBYTESCOUNT(buffer) < 1) return false; _inputBuffer.ReadFromBuffer(GETIBPOINTER(buffer), pHTTP->GetContentLength()); buffer.Ignore(pHTTP->GetContentLength()); result = ProcessSend(parts); } else { FATAL("Invalid command: %s", STR(parts[1])); result = false; } //8. Cleanup if (!result) { DeleteNearProtocol(true); EnqueueForDelete(); } //9. Done return result; }
bool Process(SSL_CTX* ctx, const char* id, const char* host, unsigned short port) { SocketSSLEx sock; if ( ! sock.Create(false)) { std::cerr << "Create socket failed!" << std::endl; return false; } if ( ! sock.Connect(ctx, host, port)) { std::cerr << "Can not connect to " << host << ":" << port << "!" << std::endl; sock.Close(); return false; } std::cout << "IDS Connected to CMS!" << std::endl; if (sizeof(SYMBOL) != sock.SendEx(SYMBOL, sizeof(SYMBOL))) { std::cerr << "Send symbol to CMS failed!" << std::endl; sock.Close(); return false; } if ( ! sock.SendPackage(id, strlen(id))) { std::cerr << "Send ID failed!" << std::endl; sock.Close(); return false; } std::cout << "Send ID '" << id << "' OK!" << std::endl; for (;;) { int n = sock.WaitData(100, true); if (n > 0) { char cmdData[4]; if (sizeof(cmdData) != sock.RecvEx(cmdData, sizeof(cmdData))) { std::cerr << "Read cmd failed!" << std::endl; break; } std::string cmd(cmdData, cmdData + 4); std::vector<char> result; if (cmd == "Send") { sending_data_tag = 1; if ( ! ProcessSend(sock, result)) { break; } } else if (cmd == "File") { sending_data_tag = 1; if ( ! ProcessUpload(sock, result)) { break; } } else if (cmd == "Down") { sending_data_tag = 1; if ( ! ProcessDownload(sock, result)) { break; } sending_data_tag = 0; check_time = time(NULL); continue; } else if (cmd == "Noop") { check_time = time(NULL); continue; } else { sending_data_tag = 1; std::string text = CreateJSON(1, "未知命令"); result.insert(result.begin(), text.begin(), text.end()); } if ( ! sock.SendPackage(&result[0], result.size())) { std::cerr << "Send result failed!" << std::endl; break; } sending_data_tag = 0; check_time = time(NULL); std::cout << "Send back data (" << result.size() << " bytes)." << std::endl; std::cout << std::string(result.begin(), result.end()) << std::endl; } } sock.Close(); return true; }