Skip to content

Commit 800ca50

Browse files
committed
s
1 parent d54dfe2 commit 800ca50

File tree

11 files changed

+48
-27
lines changed

11 files changed

+48
-27
lines changed

bsn_cpp/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ ADD_SUBDIRECTORY( plug_mgr )
109109
ADD_SUBDIRECTORY( plug_cmd )
110110
ADD_SUBDIRECTORY( plug_net )
111111
ADD_SUBDIRECTORY( plug_base64 )
112-
ADD_SUBDIRECTORY( plug_gate )
113-
ADD_SUBDIRECTORY( plug_client )
112+
#ADD_SUBDIRECTORY( plug_gate )
113+
#ADD_SUBDIRECTORY( plug_client )
114+
ADD_SUBDIRECTORY( plug_node )
114115
#ADD_SUBDIRECTORY( plug_log )
115116
#-------------------------------------------------------------------------------
116117

bsn_cpp/plug_mgr/include/i_plug.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <bsn_cpp/include/name_space.h>
44

55
#include <boost/function.hpp>
6+
#include <boost/bind.hpp>
67

78
#include <stdint.h>
89
#include <memory>
@@ -62,7 +63,7 @@ class I_Plug : public std::enable_shared_from_this<I_Plug> {
6263
virtual bool InitNeedPlug() { return true; }
6364
virtual bool ClearNeedPlug() { return true; }
6465

65-
virtual void RegPlugCmd(std::string const& strCmd, T_FuncCmd funcCmd) = 0;
66+
virtual void RegPlugCmd(std::string const& strCmd, T_FuncCmd funcCmd) {};
6667
virtual bool RegAllCmd() {
6768
RegPlugCmd("help", boost::bind(&I_Plug::CmdHelp, this, _1, _2));
6869
return true;

bsn_cpp/plug_net/src/udp_session.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ D_BsnNamespace1(plug_net)
1414
C_UDPSession::C_UDPSession(C_PlugNet::T_SPC_PlugNet spC_PlugNet, I_Address::T_SPI_Address spI_Address)
1515
: m_spC_PlugNet(spC_PlugNet)
1616
, m_spI_Address(spI_Address)
17-
, m_Socket(spC_PlugNet->GetSPI_PlugMgr()->GetIOService(), udp::endpoint(address::from_string(spI_Address->GetAddr(), spI_Address->GetPort()), )) {
17+
, m_Socket(
18+
spC_PlugNet->GetSPI_PlugMgr()->GetIOService()
19+
, udp::endpoint(
20+
address::from_string(spI_Address->GetAddr())
21+
, spI_Address->GetPort()
22+
)
23+
)
24+
{
1825

1926
};
2027

@@ -41,9 +48,9 @@ bool C_UDPSession::SendTo(I_Address::T_SPI_Address spI_Address, uint8_t* pData,
4148
}
4249

4350
//////////////////////////////////////////////////////////////////////
44-
C_UDPSession* CreateC_UDPSession(C_PlugNet::T_SPC_PlugNet spC_PlugNet) {
51+
C_UDPSession* CreateC_UDPSession(C_PlugNet::T_SPC_PlugNet spC_PlugNet,I_Address::T_SPI_Address spI_Address) {
4552
D_OutInfo();
46-
C_UDPSession* pC_UDPSession = New<C_UDPSession>(spC_PlugNet);
53+
C_UDPSession* pC_UDPSession = New<C_UDPSession>(spC_PlugNet, spI_Address);
4754
return pC_UDPSession;
4855
}
4956

@@ -53,16 +60,16 @@ void ReleaseC_UDPSession(I_UDPSession* pI_UDPSession) {
5360
Delete(pC_UDPSession);
5461
}
5562

56-
C_UDPSession::T_SPC_UDPSession C_UDPSession::NewC_UDPSession(C_PlugNet::T_SPC_PlugNet spC_PlugNet) {
63+
C_UDPSession::T_SPC_UDPSession C_UDPSession::NewC_UDPSession(C_PlugNet::T_SPC_PlugNet spC_PlugNet, I_Address::T_SPI_Address spI_Address) {
5764
D_OutInfo();
58-
auto pC_UDPSession = CreateC_UDPSession(spC_PlugNet);
65+
auto pC_UDPSession = CreateC_UDPSession(spC_PlugNet, spI_Address);
5966
auto spC_UDPSession = C_UDPSession::T_SPC_UDPSession(pC_UDPSession, ReleaseC_UDPSession);
6067
return spC_UDPSession;
6168
}
6269

63-
C_UDPSession::T_SPI_UDPSession C_UDPSession::NewI_UDPSession(C_PlugNet::T_SPC_PlugNet spC_PlugNet) {
70+
C_UDPSession::T_SPI_UDPSession C_UDPSession::NewI_UDPSession(C_PlugNet::T_SPC_PlugNet spC_PlugNet, I_Address::T_SPI_Address spI_Address) {
6471
D_OutInfo();
65-
auto spC_UDPSession = C_UDPSession::NewC_UDPSession(spC_PlugNet);
72+
auto spC_UDPSession = C_UDPSession::NewC_UDPSession(spC_PlugNet, spI_Address);
6673
auto spI_UDPSession = spC_UDPSession->GetSPI_UDPSession();
6774
return spI_UDPSession;
6875
}

bsn_cpp/plug_net/src/udp_session.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <bsn_cpp/plug_net/include/i_tcp_listen.h>
3+
#include <bsn_cpp/plug_net/include/i_udp_session.h>
44
#include <bsn_cpp/plug_net/src/plug_net.h>
55

66

@@ -24,8 +24,8 @@ class C_UDPSession : public I_UDPSession {
2424
virtual bool SendTo(I_Address::T_SPI_Address spI_Address, uint8_t* pData, uint32_t u32Len) override;
2525

2626
public:
27-
static T_SPC_UDPSession NewC_UDPSession(C_PlugNet::T_SPC_PlugNet spC_PlugNet);
28-
static T_SPI_UDPSession NewI_UDPSession(C_PlugNet::T_SPC_PlugNet spC_PlugNet);
27+
static T_SPC_UDPSession NewC_UDPSession(C_PlugNet::T_SPC_PlugNet spC_PlugNet, I_Address::T_SPI_Address spI_Address);
28+
static T_SPI_UDPSession NewI_UDPSession(C_PlugNet::T_SPC_PlugNet spC_PlugNet, I_Address::T_SPI_Address spI_Address);
2929

3030
T_SPC_UDPSession GetSPC_UDPSession();
3131
T_Socket& GetSocket();
@@ -37,7 +37,7 @@ class C_UDPSession : public I_UDPSession {
3737
public:
3838
C_PlugNet::T_SPC_PlugNet m_spC_PlugNet;
3939
I_Address::T_SPI_Address m_spI_Address;
40-
I_UDPSession::T_Socket m_Socket;
40+
C_UDPSession::T_Socket m_Socket;
4141
boost::asio::ip::udp::endpoint m_remoteEndPoint;
4242
};
4343
//////////////////////////////////////////////////////////////////////

bsn_cpp/plug_node/include/i_plug_node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include <stdint.h>
99

10-
D_BsnNamespace1(plug_cmd)
10+
D_BsnNamespace1(plug_node)
1111
//////////////////////////////////////////////////////////////////////
1212
class I_PlugNode : public D_N1(plug_mgr)::I_Plug {
1313
public:

bsn_cpp/plug_node/src/child.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include <bsn_cpp/include/name_space.h>
4+
35
#include <memory>
46

57
D_BsnNamespace1(plug_node)

bsn_cpp/plug_node/src/node.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <bsn_cpp/plug_node/src/node.h>
2+
#include <bsn_cpp/plug_node/src/plug.h>
23

34
#include <bsn_cpp/include/d_out.h>
45
#include <bsn_cpp/include/new.hpp>
@@ -8,8 +9,8 @@ D_BsnNamespace1(plug_node)
89
//////////////////////////////////////////////////////////////////////
910
C_Node::C_Node(C_Node::T_SPC_Plug spC_Plug, C_Node::T_SPI_Address spI_AddressListen, C_Node::T_Id id)
1011
: m_spC_Plug(spC_Plug)
11-
, m_spI_AddressListen(spI_AddressListen)
1212
, m_id(id)
13+
, m_spI_AddressListen(spI_AddressListen)
1314
{
1415
D_OutInfo();
1516
}

bsn_cpp/plug_node/src/node.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <bsn_cpp/plug_net/include/i_tcp_session.h>
88
#include <bsn_cpp/plug_net/include/i_address.h>
99

10+
#include <bsn_cpp/include/name_space.h>
11+
1012
#include <memory>
1113

1214
D_BsnNamespace1(plug_node)
@@ -16,6 +18,7 @@ class C_Plug;
1618
class C_Node : public std::enable_shared_from_this<C_Node> {
1719
public:
1820
typedef std::shared_ptr<C_Node> T_SPC_Node;
21+
typedef std::shared_ptr<C_Plug> T_SPC_Plug;
1922
typedef uint32_t T_Id;
2023
typedef std::map<C_Child::T_Id, C_Child::T_SPC_Child> T_Id2Child;
2124
typedef D_N1(plug_net)::I_TCPListen::T_SPI_TCPListen T_SPI_TCPListen;
@@ -24,17 +27,17 @@ class C_Node : public std::enable_shared_from_this<C_Node> {
2427

2528
public:
2629
C_Node::T_Id GetId() const;
30+
bool StartTCPListen();
31+
bool SetParentAddr(C_Node::T_SPI_Address spI_AddressParent);
2732

2833
public:
2934
static C_Node::T_SPC_Node NewC_Node(C_Node::T_SPC_Plug spC_Plug, C_Node::T_SPI_Address spI_AddressListen, C_Node::T_Id id);
3035

3136
C_Node::T_SPC_Node GetSPC_Node();
3237

33-
bool StartTCPListen();
3438
C_Node::T_SPI_TCPSession FuncNew();
3539
void FuncOnAccept(C_Node::T_SPI_TCPSession spI_TCPSession);
3640

37-
bool SetParentAddr(C_Node::T_SPI_Address spI_AddressParent);
3841

3942
public:
4043
C_Node(C_Node::T_SPC_Plug spC_Plug, C_Node::T_SPI_Address spI_AddressListen, C_Node::T_Id id);

bsn_cpp/plug_node/src/parent.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include <bsn_cpp/include/name_space.h>
4+
35
#include <memory>
46

57
D_BsnNamespace1(plug_node)

bsn_cpp/plug_node/src/plug.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ void C_Plug::CmdStartNode(bool bShowHelp, std::string const& strParam) {
9191
}
9292

9393
std::vector<std::string> params;
94-
boost::algorithm::split(SplitVec, strTmp1, is_any_of(" "), boost::token_compress_on);
95-
if (SplitVec.size() != 5) {
94+
boost::algorithm::split(params, strParam, boost::algorithm::is_any_of(" "), boost::token_compress_on);
95+
if (params.size() != 5) {
9696
return CmdStartNode(true, strParam);
9797
}
9898

@@ -121,7 +121,7 @@ int C_Plug::StartNode(
121121
return -1;
122122
}
123123

124-
auto spI_PlugNet = m_spC_Plug->GetSPI_PlugNet();
124+
auto spI_PlugNet = GetSPI_PlugNet();
125125
if (!spI_PlugNet) {
126126
return -2;
127127
}
@@ -146,17 +146,17 @@ int C_Plug::StartNode(
146146
return 0;
147147
}
148148

149-
C_Node::T_SPC_Node C_Node::GetNode(C_Node::T_Id id) {
149+
C_Node::T_SPC_Node C_Plug::GetNode(C_Node::T_Id id) {
150150
D_OutInfo();
151151

152152
auto itor = m_Id2Node.find(id);
153153
if (itor == m_Id2Node.end()) {
154154
return nullptr;
155155
}
156-
return itor.second;
156+
return itor->second;
157157
}
158158

159-
int C_Node::AddNode(C_Node::T_SPC_Node spC_Node) {
159+
int C_Plug::AddNode(C_Node::T_SPC_Node spC_Node) {
160160
D_OutInfo();
161161

162162
if (!spC_Node) {
@@ -168,7 +168,7 @@ int C_Node::AddNode(C_Node::T_SPC_Node spC_Node) {
168168
return -2;
169169
}
170170

171-
if (!GetNode(id)) {
171+
if (GetNode(id)) {
172172
return -3;
173173
}
174174

@@ -183,7 +183,7 @@ C_Plug* CreateC_Plug(void* pData) {
183183
return pC_Plug;
184184
}
185185

186-
void ReleaseC_Plug(I_Plug* pI_Plug) {
186+
void ReleaseC_Plug(D_N1(plug_mgr)::I_Plug* pI_Plug) {
187187
D_OutInfo();
188188
C_Plug* pC_Plug = static_cast<C_Plug*>(pI_Plug);
189189
Delete(pC_Plug);
@@ -196,7 +196,7 @@ C_Plug::T_SPC_Plug C_Plug::NewC_Plug(void* pData) {
196196
return spC_Plug;
197197
}
198198

199-
I_Plug::T_SPI_Plug C_Plug::NewI_Plug(void* pData) {
199+
D_N1(plug_mgr)::I_Plug::T_SPI_Plug C_Plug::NewI_Plug(void* pData) {
200200
D_OutInfo();
201201
auto spC_Plug = C_Plug::NewC_Plug(pData);
202202
auto spI_Plug = spC_Plug->GetSPI_Plug();

0 commit comments

Comments
 (0)