-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsdk.cpp
More file actions
49 lines (40 loc) · 1.01 KB
/
sdk.cpp
File metadata and controls
49 lines (40 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* sdk.cpp
*
* Created on: 2016年7月28日
* Author: wong
*/
#include "sdk.h"
#include <stddef.h>
#include "SDKManager.h"
#include "Common.h"
SDKManager* g_sdk = NULL;
int Init(int nDevType, char* strDevSN, bool bAutoLogin/*=true*/)
{
if (g_sdk != NULL)
{
return -1;
}
std::string sn(reinterpret_cast<char*>(strDevSN));
static SDKManager mgr(nDevType, sn, bAutoLogin);
g_sdk = &mgr;//new SDKManager(nDevType, sn, bAutoLogin);
return 0;
}
void Release()
{
//SAFE_DELETE(g_sdk);
}
int CreateClientObj(CCMS_NETADDR* pServerAddr, int nProtocolType, bool bRaw)
{
const std::string& ip = ARRAY2STR(pServerAddr->chIP);
return g_sdk->NewClient(nProtocolType, ip, pServerAddr->nPort, bRaw);
}
int CreateServerObj(CCMS_NETADDR* pListenAddr, int nProtocolType, bool bRaw)
{
const std::string& ip = ARRAY2STR(pListenAddr->chIP);
return g_sdk->NewServer(nProtocolType, ip, pListenAddr->nPort, bRaw);
}
int DeleteObj(int nHandle)
{
return g_sdk->ReleaseObj(nHandle);
}