1
This commit is contained in:
parent
0ddb1e12ef
commit
741f5ccdce
@ -140,28 +140,9 @@ void GCListener::UnInit()
|
|||||||
tcp_listener_ = nullptr;
|
tcp_listener_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCListener::ForwardUpStreamMsg(f8::MsgHdr& hdr)
|
void GCListener::SendBuf(unsigned short sockhandle, char* buf, int buflen)
|
||||||
{
|
{
|
||||||
char* buff = (char*)malloc(sizeof(f8::PackHead) + hdr.buflen);
|
tcp_listener_->SendClientMsg(sockhandle, buf, buflen);
|
||||||
f8::PackHead* head = (f8::PackHead*)buff;
|
|
||||||
head->packlen = hdr.buflen;
|
|
||||||
head->msgid = hdr.msgid;
|
|
||||||
head->seqid = hdr.seqid;
|
|
||||||
head->magic_code = f8::MAGIC_CODE;
|
|
||||||
head->ext_len = hdr.buflen >> 16;
|
|
||||||
if (hdr.buflen > 0) {
|
|
||||||
memmove(buff + sizeof(f8::PackHead), hdr.buf, hdr.buflen);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef USE_KCP
|
|
||||||
auto session = GetKcpSessionBySocketHandle(hdr.socket_handle);
|
|
||||||
if (session) {
|
|
||||||
session->SendClientMsg(buff, sizeof(f8::PackHead) + head->packlen);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
tcp_listener_->SendClientMsg(hdr.socket_handle, buff, sizeof(f8::PackHead) + head->packlen);
|
|
||||||
#endif
|
|
||||||
free(buff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCListener::SendText(unsigned short sockhandle, const std::string& text)
|
void GCListener::SendText(unsigned short sockhandle, const std::string& text)
|
||||||
|
@ -26,7 +26,7 @@ class GCListener : public a8::Singleton<GCListener>
|
|||||||
f8::Net_SendMsg(tcp_listener_, socket_handle, 0, msgid, msg);
|
f8::Net_SendMsg(tcp_listener_, socket_handle, 0, msgid, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardUpStreamMsg(f8::MsgHdr& hdr);
|
void SendBuf(unsigned short sockhandle, char* buf, int buflen);
|
||||||
void SendText(unsigned short sockhandle, const std::string& text);
|
void SendText(unsigned short sockhandle, const std::string& text);
|
||||||
|
|
||||||
void ForceCloseClient(unsigned short sockhandle);
|
void ForceCloseClient(unsigned short sockhandle);
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include "downstream.h"
|
#include "downstream.h"
|
||||||
#include "upstream.h"
|
#include "upstream.h"
|
||||||
|
#include "longsessionmgr.h"
|
||||||
|
#include "GCListener.h"
|
||||||
|
|
||||||
#include "ss_proto.pb.h"
|
#include "ss_proto.pb.h"
|
||||||
|
|
||||||
@ -18,7 +20,26 @@ void DownStream::ReBindUpStream(std::weak_ptr<UpStream> up)
|
|||||||
|
|
||||||
void DownStream::ForwardUpStreamMsg(f8::MsgHdr& hdr)
|
void DownStream::ForwardUpStreamMsg(f8::MsgHdr& hdr)
|
||||||
{
|
{
|
||||||
|
char* buff = (char*)malloc(sizeof(f8::PackHead) + hdr.buflen);
|
||||||
|
f8::PackHead* head = (f8::PackHead*)buff;
|
||||||
|
head->packlen = hdr.buflen;
|
||||||
|
head->msgid = hdr.msgid;
|
||||||
|
head->seqid = hdr.seqid;
|
||||||
|
head->magic_code = f8::MAGIC_CODE;
|
||||||
|
head->ext_len = hdr.buflen >> 16;
|
||||||
|
if (hdr.buflen > 0) {
|
||||||
|
memmove(buff + sizeof(f8::PackHead), hdr.buf, hdr.buflen);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef USE_KCP
|
||||||
|
auto session = GetKcpSessionBySocketHandle(hdr.socket_handle);
|
||||||
|
if (session) {
|
||||||
|
session->SendClientMsg(buff, sizeof(f8::PackHead) + head->packlen);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
GCListener::Instance()->SendBuf(hdr.socket_handle, buff, sizeof(f8::PackHead) + head->packlen);
|
||||||
|
#endif
|
||||||
|
free(buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownStream::OnClose()
|
void DownStream::OnClose()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user