wangzhengquan
2020-06-19 1b26f1dd275e7ff947fcf2ecdbbad8f6bc1e0b49
update
1 文件已重命名
7个文件已修改
30 ■■■■ 已修改文件
Makefile 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
data/config.txt 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/Makefile 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/netdisk_service 补丁 | 查看 | 原始文档 | blame | 历史
service/netdisk_service.c 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/test_client 补丁 | 查看 | 原始文档 | blame | 历史
service/test_client.c 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/test_netdisk.c 补丁 | 查看 | 原始文档 | blame | 历史
Makefile
@@ -20,14 +20,14 @@
PACKAGE_NAME=netdisk_bin.tar.gz
package:
    ls ./build/bin > /dev/null  2> /dev/null ||  mkdir -p ./build/bin && cp ./service/netdisk_service ./build/bin/
    ls ./build/bin > /dev/null  2> /dev/null ||  mkdir -p ./build/bin && cp ./service/netdisk_service ./build/bin/ && cp ./service/test_client ./build/bin/
    ls ./build/common > /dev/null 2> /dev/null  || mkdir -p ./build/common && cp ./common/libusgcommon.a ./build/common && cp ./common/libusgcommon.so ./build/common
    cp -a ./data ./build
    cp -avx ./script/* ./build
    tar -czvf $(PACKAGE_NAME) build
tarname = netdis_str.tar.gz
tarname = netdisk_src.tar.gz
tar:
    rm -f $(tarname)
data/config.txt
@@ -1,8 +1,8 @@
# nng本地服务地址
local_url=tcp://127.0.0.1:8899
server_url=tcp://127.0.0.1:8801
# nng远程调用地址地址
remote_url=tcp://127.0.0.1:9988
client_url=tcp://127.0.0.1:7701
# 负责下载任务的线程池的数量
workers=4
service/Makefile
@@ -28,6 +28,8 @@
netdisk_service: $(ROOT)/device/hcnetdisk.c $(ROOT)/device/netdisk_factory.c login_store.c request_handler.c properties_config.c
test_client: test_client.c properties_config.c
test: $(ROOT)/device/hcnetdisk.c
test_properties: properties_config.c
service/netdisk_service
Binary files differ
service/netdisk_service.c
@@ -17,7 +17,6 @@
int  WORKERS ;
std::string localUrl;
std::string remoteUrl;
PropertiesConfig config("../data/config.txt");
@@ -201,8 +200,7 @@
{
  //环境变量初始化
  WORKERS = config.getInt("workers");
  localUrl = config.get("local_url");
  remoteUrl = config.get("remote_url");
  remoteUrl = config.get("client_url");
  //海康设备环境初始化
  Netdisk_EnvConfig hcEnvConfig;
@@ -215,7 +213,7 @@
  initThreadPool();
  startServer(localUrl.c_str());
  startServer(config.get("server_url").c_str());
  HCNetdisk::netdisk_deinit();
service/test_client
Binary files differ
service/test_client.c
@@ -1,12 +1,14 @@
#include "usg_common.h"
#include "netdisk.h"
#include "hcnetdisk.h"
#include "properties_config.h"
#include <jsoncpp/json/json.h>
#include <nng/nng.h>
#include <nng/protocol/reqrep0/rep.h>
#include <nng/protocol/reqrep0/req.h>
const char *url = "tcp://127.0.0.1:8899";
const char *localUrl = "tcp://127.0.0.1:9988";
PropertiesConfig config("../data/config.txt");
void
fatal(const char *func, int rv)
{
@@ -152,7 +154,7 @@
    if ((rv = nng_req0_open(&sock)) != 0) {
        fatal("nng_socket", rv);
    }
    if ((rv = nng_dial(sock, url, NULL, 0)) != 0) {
    if ((rv = nng_dial(sock, config.get("server_url").c_str(), NULL, 0)) != 0) {
        fatal("nng_dial", rv);
    }
    //printf("CLIENT: SENDING DATE REQUEST\n");
@@ -187,7 +189,7 @@
}
int
server()
server(const char *url)
{
    nng_socket sock;
    int        rv;
@@ -195,7 +197,7 @@
    if ((rv = nng_rep0_open(&sock)) != 0) {
        fatal("nng_rep0_open", rv);
    }
    if ((rv = nng_listen(sock, localUrl, NULL, 0)) != 0) {
    if ((rv = nng_listen(sock, url, NULL, 0)) != 0) {
        fatal("nng_listen", rv);
    }
    for (;;) {
@@ -230,7 +232,7 @@
    pthread_t tid;
    pthread_create(&tid, NULL, client, NULL);
     
    server();
    server(config.get("client_url").c_str());
    return 0;
    
}
service/test_netdisk.c