From a5fc9f0acaa8b92c8d78f060cd4cdabab2793c62 Mon Sep 17 00:00:00 2001
From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期四, 17 八月 2017 10:30:34 +0800
Subject: [PATCH] merge home base

---
 VisitFace/RtspNativeCodec/app/src/main/cpp/RemoteFuncClient.cpp |  102 ++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 88 insertions(+), 14 deletions(-)

diff --git a/VisitFace/RtspNativeCodec/app/src/main/cpp/RemoteFuncClient.cpp b/VisitFace/RtspNativeCodec/app/src/main/cpp/RemoteFuncClient.cpp
index 5bc9c0d..623fdc0 100644
--- a/VisitFace/RtspNativeCodec/app/src/main/cpp/RemoteFuncClient.cpp
+++ b/VisitFace/RtspNativeCodec/app/src/main/cpp/RemoteFuncClient.cpp
@@ -5,22 +5,96 @@
 #include "RemoteFuncClient.h"
 #include "RemoteFunc.h"
 #include "RtspNativeCodecJNIClient.h"
-RemoteServer<RtspFaceDetectImpl> remoteServer("127.0.0.1",8111);
-void startRemoteServer(){
-    remoteServer.start();
+
+#include <string>
+#include <iostream>
+using namespace std;
+
+//#todo 淇敼鏈嶅姟绾跨▼鏋勯�犲弬鏁颁紶鍏ユ柟寮�
+RemoteServer<RtspFaceDetectImpl> remoteServer("192.168.1.97", 8111);
+static RtspFaceViewClient* rtspFaceViewClient = nullptr;
+
+void startRemoteServer()
+{
+	LOG_ERROR << "pansen : this is clinet" << std::endl;
+	remoteServer.start();
+
+    //#todo 璋冪敤浣嶇疆绉诲姩
+//    try
+//    {
+//        RtspFaceViewClient rtspFaceViewClient = RtspFaceViewClient();
+//        RtspFaceView::Client& rClient = rtspFaceViewClient.getClient();
+//
+//        auto& waitScope = rtspFaceViewClient.getWaitScope();
+//        //auto  request = rClient.abcdef();
+//       // auto sendAct = request.send();
+//       // sendAct.wait(waitScope);
+//    }
+//    catch (const kj::Exception& e)
+//    {
+//        cout << e.getDescription().cStr() << endl;
+//        return;
+//    }
+    //#end
 }
-RtspFaceViewClient rtspFaceViewClient;
-RtspFaceViewClient& RtspFaceViewClient(){
-    return rtspFaceViewClient;
+
+RtspFaceViewClient * getRtspFaceViewClient()
+{
+    if(rtspFaceViewClient == nullptr)
+        rtspFaceViewClient = new RtspFaceViewClient;
+	return rtspFaceViewClient;
 }
-RtspFaceViewClient::RtspFaceViewClient():rpcClient("127.0.0.1",8112),
-                                         RtspFaceView::Client(rpcClient.getMain<RtspFaceView>())
+
+RtspFaceViewClient::RtspFaceViewClient() :
+        rpcClient(nullptr)
 {}
-::kj::WaitScope& RtspFaceViewClient::getWaitScope(){
-    return rpcClient.getWaitScope();
+
+RtspFaceView::Client& RtspFaceViewClient::getClient()
+{
+    if (client == nullptr) {
+        try
+        {
+            client = new RtspFaceView::Client(getEzRpcClient()->getMain<RtspFaceView>());
+        }
+        catch (const kj::Exception& e)
+        {
+            delete client;
+            client = nullptr;
+            throw e;
+        }
+    }
+    return *client;
 }
-::kj::Promise<void> RtspFaceDetectImpl::fireFaceCountListener(FireFaceCountListenerContext context) {
-    auto results = context.getResults();
-    remoteFireFaceCountListener(context.getParams(), results);
+
+::kj::WaitScope &RtspFaceViewClient::getWaitScope()
+{
+    return getEzRpcClient()->getWaitScope();
+}
+
+capnp::EzRpcClient * RtspFaceViewClient::getEzRpcClient()
+{
+    if (rpcClient == nullptr) {
+        try
+        {
+            //#todo ip modify
+            rpcClient = new capnp::EzRpcClient("192.168.1.94", 8112);
+            //rpcClient = new capnp::EzRpcClient("192.168.1.71", 8112);
+        }
+        catch (const kj::Exception& e)
+        {
+            delete rpcClient;
+            rpcClient = nullptr;
+            throw e;
+        }
+    }
+    return rpcClient;
+}
+
+::kj::Promise<void> RtspFaceDetectImpl::fireFaceCountListener(FireFaceCountListenerContext context)
+{
+	auto results = context.getResults();
+    LOG_ERROR << "!!!!!!!!!!!!!!!!!!!!!WHO  find face!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << LOG_ENDL;
+	remoteFireFaceCountListener(context.getParams(), results);
     context.setResults(results);
-}
\ No newline at end of file
+    return kj::READY_NOW;
+}

--
Gitblit v1.8.0