예제 #1
0
void PushService::onPing()
{
    g_sm->checkCurrentOn(ServiceMgr::PUSH);

    BfPingData data;
    data.set_message("ctpgateway");
    for (auto client : clients_) {
        client->OnPing(data);
    }
}
예제 #2
0
void PushService::onPing()
{
    g_sm->checkCurrentOn(ServiceMgr::PUSH);

    //google::protobuf::Arena arena;
    //BfPingData* data = google::protobuf::Arena::CreateMessage<BfPingData>(&arena);
    //data->set_message("bftrader");
    //for (auto proxy : proxyClients_) {
    //    proxy->OnPing(*data);
    //}
    BfPingData data;
    data.set_message("bftrader");
    for (auto proxy : proxyClients_) {
        proxy->OnPing(data);
    }
}
예제 #3
0
void DbService::onPing()
{
    //BfLog(__FUNCTION__);
    g_sm->checkCurrentOn(ServiceMgr::PUSH);

    if (client_) {
        // ping datafeed
        BfPingData req;
        req.set_message(client_->clientId().toStdString());
        bool ok = client_->Ping(req);

        // ready是没必要的,用ping检测最好=
        if (ok || client_->ready()) {
        }
    }
}
예제 #4
0
    // ref: grpc\test\cpp\interop\interop_client.cc
    bool Ping(const BfPingData& req)
    {
        grpc::ClientContext ctx;
        std::chrono::system_clock::time_point deadline = std::chrono::system_clock::now() + std::chrono::milliseconds(deadline_);
        ctx.set_deadline(deadline);
        ctx.AddMetadata("clientid", clientId_.toStdString());

        BfPingData resp;
        grpc::Status status = stub_->Ping(&ctx, req, &resp);
        if (!status.ok()) {
            BfLog("Datafeed->Ping fail,code:%d,msg:%s", status.error_code(), status.error_message().c_str());
            return false;
        }

        if (req.message() != resp.message()) {
            BfLog("Datafeed->Ping fail,ping:%s,pong:%s", req.message().c_str(), resp.message().c_str());
            return false;
        }

        return true;
    }