收发消息,箭头之前使用接口名称
This commit is contained in:
parent
02bda21d79
commit
5ea8e79428
|
@ -180,7 +180,9 @@ void LinkClient::OnReceive(LinkMessage& msg)
|
||||||
TS("LinkClient::OnReceive");
|
TS("LinkClient::OnReceive");
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
debug_printf("Link <= ");
|
auto obj = dynamic_cast<Object*>(Master);
|
||||||
|
obj->Show(false);
|
||||||
|
debug_printf(" <= ");
|
||||||
msg.Show(true);
|
msg.Show(true);
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
|
@ -269,7 +271,9 @@ bool LinkClient::Invoke(const String& action, const Json& args) {
|
||||||
if (_g_seq == 0)_g_seq++;
|
if (_g_seq == 0)_g_seq++;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
debug_printf("Link => ");
|
auto obj = dynamic_cast<Object*>(Master);
|
||||||
|
obj->Show(false);
|
||||||
|
debug_printf(" => ");
|
||||||
msg.Show(true);
|
msg.Show(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -300,7 +304,9 @@ bool LinkClient::Reply(const String& action, int seq, int code, const String& re
|
||||||
msg.Code = 1;
|
msg.Code = 1;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
debug_printf("Link => ");
|
auto obj = dynamic_cast<Object*>(Master);
|
||||||
|
obj->Show(false);
|
||||||
|
debug_printf(" => ");
|
||||||
msg.Show(true);
|
msg.Show(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,23 @@ void TinyLink::Open()
|
||||||
TS("TinyLink::Open");
|
TS("TinyLink::Open");
|
||||||
assert(Port, "未指定Port");
|
assert(Port, "未指定Port");
|
||||||
|
|
||||||
|
Port->Register(Dispatch, this);
|
||||||
|
Port->Open();
|
||||||
|
|
||||||
|
if (PingTime > 0) _task = Sys.AddTask(&TinyLink::LoopTask, this, 0, PingTime * 1000, "微联定时");
|
||||||
|
|
||||||
|
Opened = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TinyLink::Listen()
|
||||||
|
{
|
||||||
|
if (Opened) return;
|
||||||
|
|
||||||
|
TS("TinyLink::Open");
|
||||||
|
assert(Port, "未指定Port");
|
||||||
|
|
||||||
|
Port->Register(Dispatch, this);
|
||||||
Port->Open();
|
Port->Open();
|
||||||
_task = Sys.AddTask(&TinyLink::LoopTask, this, 0, 1000, "微联定时");
|
|
||||||
|
|
||||||
Opened = true;
|
Opened = true;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +49,7 @@ void TinyLink::Close()
|
||||||
{
|
{
|
||||||
if (!Opened) return;
|
if (!Opened) return;
|
||||||
|
|
||||||
|
Port->Register(nullptr, nullptr);
|
||||||
Port->Close();
|
Port->Close();
|
||||||
Sys.RemoveTask(_task);
|
Sys.RemoveTask(_task);
|
||||||
|
|
||||||
|
@ -77,7 +93,9 @@ void TinyLink::OnReceive(LinkMessage& msg)
|
||||||
TS("TinyLink::OnReceive");
|
TS("TinyLink::OnReceive");
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
debug_printf("Link <= ");
|
auto obj = dynamic_cast<Object*>(Port);
|
||||||
|
obj->Show(false);
|
||||||
|
debug_printf(" <= ");
|
||||||
msg.Show(true);
|
msg.Show(true);
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
|
@ -102,7 +120,9 @@ bool TinyLink::Send(LinkMessage& msg, const String& data) {
|
||||||
msg.Code = 1;
|
msg.Code = 1;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
debug_printf("Link => ");
|
auto obj = dynamic_cast<Object*>(Port);
|
||||||
|
obj->Show(false);
|
||||||
|
debug_printf(" => ");
|
||||||
str.Show(true);
|
str.Show(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,9 @@ public:
|
||||||
|
|
||||||
TinyLink();
|
TinyLink();
|
||||||
|
|
||||||
void Open();
|
void Open(); // 打开连接,登录并定时心跳
|
||||||
void Close();
|
void Close(); // 关闭连接
|
||||||
|
void Listen(); // 打开并监听连接,作为服务端,没有登录和心跳
|
||||||
|
|
||||||
// 发送消息
|
// 发送消息
|
||||||
bool Send(LinkMessage& msg, const String& data);
|
bool Send(LinkMessage& msg, const String& data);
|
||||||
|
|
|
@ -112,6 +112,7 @@
|
||||||
<ClCompile Include="..\Link\LinkClient.cpp" />
|
<ClCompile Include="..\Link\LinkClient.cpp" />
|
||||||
<ClCompile Include="..\Link\LinkConfig.cpp" />
|
<ClCompile Include="..\Link\LinkConfig.cpp" />
|
||||||
<ClCompile Include="..\Link\LinkMessage.cpp" />
|
<ClCompile Include="..\Link\LinkMessage.cpp" />
|
||||||
|
<ClCompile Include="..\Link\TinyLink.cpp" />
|
||||||
<ClCompile Include="..\Message\Api.cpp" />
|
<ClCompile Include="..\Message\Api.cpp" />
|
||||||
<ClCompile Include="..\Message\BinaryPair.cpp" />
|
<ClCompile Include="..\Message\BinaryPair.cpp" />
|
||||||
<ClCompile Include="..\Message\Controller.cpp" />
|
<ClCompile Include="..\Message\Controller.cpp" />
|
||||||
|
|
|
@ -602,5 +602,8 @@
|
||||||
<ClCompile Include="..\Message\Api.cpp">
|
<ClCompile Include="..\Message\Api.cpp">
|
||||||
<Filter>Message</Filter>
|
<Filter>Message</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Link\TinyLink.cpp">
|
||||||
|
<Filter>Link</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue