JNetLibray
로딩중...
검색중...
일치하는것 없음
JNetCore.h
이 파일의 문서화 페이지로 가기
1#pragma once
2#include "CommStructs.h"
3#include "CommTypes.h"
4#include "WinSocketAPI.h"
5#define JBUFF_DIRPTR_MANUAL_RESET
6#include "JBuffer.h"
7#include "LockFreeQueue.h"
8#include "TlsMemPool.h"
9#include "JNetDB.h"
10
15namespace jnet {
16
18// IOCP 완료 통지 식별 (LPOVERLAPPED)
20#define IOCP_COMPLTED_LPOVERLAPPED_DISCONNECT -1
21#define IOCP_COMPLTED_LPOVERLAPPED_SENDPOST_REQ -2
22
23#define CALCULATE_TRANSACTION_PER_SECOND
24
25#define ASSERT
26
27 using namespace std;
29
30 /********************************************************************
31 * JNetCore
32 ********************************************************************/
41 {
42 protected:
44 struct JNetSession;
45
46 private:
47 std::vector<JNetSession*> m_Sessions;
49 LockFreeQueue<uint16> m_SessionIndexQueue;
51
52 HANDLE m_IOCP;
54 std::vector<HANDLE> m_IocpWorkerThrdHnds;
55 std::vector<uint32> m_IocpWorkerThrdIDs;
56
57 TlsMemPoolManager<JBuffer, true, false> m_TlsMemPoolMgr;
58
62
63 public:
73 uint16 maximumOfSessions,
74 uint32 numOfIocpConcurrentThrd, uint16 numOfIocpWorkerThrd,
75 size_t tlsMemPoolUnitCnt, size_t tlsMemPoolUnitCapacity,
76 uint32 memPoolBuffAllocSize,
77 uint32 sessionRecvBuffSize,
78 bool calcTpsThread
79 );
80 ~JNetCore();
81
82 bool Start();
83 void Stop();
85 {
87 }
88
89 protected:
91
92 protected:
96 JNetSession* CreateNewSession(SOCKET sock);
97
101 bool RegistSessionToIOCP(JNetSession* session);
102
106 bool DeleteSession(SessionID64 sessionID);
107
108 void Disconnect(SessionID64 sessionID);
109
114 bool SendPacket(SessionID64 sessionID, JBuffer* sendPktPtr, bool postToWorker = false);
115
119 bool SendPacketBlocking(SessionID64 sessionID, JBuffer* sendPktPtr);
120
124 bool BufferSendPacket(SessionID64 sessionID, JBuffer* sendPktPtr);
125
129 bool SendBufferedPacket(SessionID64 sessionID, bool postToWorker = false);
130
135
137 inline JBuffer* AllocSerialBuff() {
138 JBuffer* msg = m_TlsMemPoolMgr.GetTlsMemPool().AllocMem(1, m_MemPoolBuffAllocSize);
139 msg->ClearBuffer();
140 return msg;
141 }
142
144 inline void FreeSerialBuff(JBuffer* buff) {
145 m_TlsMemPoolMgr.GetTlsMemPool().FreeMem(buff);
146 }
147
149 inline void AddRefSerialBuff(JBuffer* buff) {
150 m_TlsMemPoolMgr.GetTlsMemPool().IncrementRefCnt(buff, 1);
151 }
152
153 public:
155 return m_TlsMemPoolMgr.GetAllocatedMemUnitCnt();;
156 }
157 inline int GetSessionCount() {
158 return m_MaximumOfSessions - m_SessionIndexQueue.GetSize();
159 }
160
161 protected:
165 virtual bool OnWorkerThreadCreate(HANDLE thHnd);
166
168 virtual void OnAllWorkerThreadCreate();
169
171 virtual void OnWorkerThreadStart();
172
174 virtual void OnWorkerThreadEnd();
175
185 virtual void OnRecvCompletion(SessionID64 sessionID, JBuffer& recvRingBuffer) = 0;
186
189 virtual void OnSessionLeave(SessionID64 sessionID);
190
191 virtual void OnError();
192
193
194 private:
198 JNetSession* AcquireSession(SessionID64 sessionID); // called by SendPacket, BufferedSendPacket, SendBufferedPacket
199
202 void ReturnSession(JNetSession* session); // " "
203
207 void SendPost(SessionID64 sessionID, bool onSendFlag = false); // called by SendPacket, SendBufferedPacket
208 // IOCP 송신 완료 통지 및 IOCP_COMPLTED_LPOVERLAPPED_SENDPOST_REQ 요청 시
209
212 void SendPostRequest(SessionID64 sessionID); // IOCP_COMPLTED_LPOVERLAPPED_SENDPOST_REQ 식별자로 PostQueuedCompletionStatus 호출
213 // IOCP 작업자 스레드에 SendPost 호출 책임 전가
215 void FreeBufferedSendPacket(LockFreeQueue<JBuffer*>& sendBufferQueue, queue<JBuffer*>& sendPostedQueue);
216
218 static UINT __stdcall WorkerThreadFunc(void* arg);
219
221 void Proc_DeleteSession(JNetSession* session);
223 void Proc_SendPostRequest(JNetSession* session);
225 void Proc_RecvCompletion(JNetSession* session, DWORD transferred);
227 void Proc_SendCompletion(JNetSession* session);
228
229protected:
231
232private:
233 static const int NUM_OF_TPS_ITEM = 4;
240
242 static UINT __stdcall CalcTpsThreadFunc(void* arg);
246
247public:
254
255 inline void IncrementRecvTransactions(bool threadSafe, UINT incre) {if (incre > 0) {IncrementTransactions(RECV_TRANSACTION, threadSafe, incre);}}
256 inline void IncrementSendTransactions(bool threadSafe, UINT incre) {if (incre > 0) {IncrementTransactions(SEND_TRANSACTION, threadSafe, incre);}}
257 inline void IncrementAcceptTransactions(bool threadSafe = false, UINT incre = 1) {if (incre > 0) {IncrementTransactions(ACCEPT_TRANSACTION, threadSafe, incre);}}
258
259private:
260 inline void IncrementTransactions(BYTE type, bool threadSafe = false, UINT incre = 1) {
261 if (threadSafe) {
262 if (incre == 1) {InterlockedIncrement(&m_Transactions[type]);}
263 else {InterlockedAdd((LONG*)&m_Transactions[type], incre);}
264 }
265 else {
266 m_Transactions[type] += incre;
267 }
268 }
269 inline LONG GetTransactionsPerSecond(BYTE type) {return m_TransactionsPerSecond[type];}
270 inline UINT64 GetTotalTransactions(BYTE type) {return m_TotalTransaction[type];}
271 };
272
280 struct SessionID {
283
284 SessionID() : idx(0), increment(0) {}
286 memcpy(this, &id64, sizeof(SessionID64));
287 }
288 SessionID(uint64 allocIdx, uint64 allocIncre) : idx(allocIdx), increment(allocIncre) {}
289
290 // 형변환 연산자 오버로딩을 통해
291 // uint64 정수형으로 손쉽게 변환
292 // => uint64 자료형이 필요한 상황에서 활용
293 // ex) InterlockedIncrement ..
294 operator uint64() {
295 return *reinterpret_cast<uint64*>(this);
296 }
297 };
299 struct SessionRef {
302
305 memcpy(this, &ref32, sizeof(int32));
306 }
307 SessionRef(int32 ref, int32 flag) : refCnt(ref), releaseFlag(flag) {}
308
310 memcpy(this, &ref32, sizeof(int32));
311 }
312 operator int32() {
313 return *reinterpret_cast<int32*>(this);
314 }
315 };
316
320
321 SOCKET m_Sock;
322 WSAOVERLAPPED m_RecvOverlapped;
323 WSAOVERLAPPED m_SendOverlapped;
325 LockFreeQueue<JBuffer*> m_SendBufferQueue;
326 queue<JBuffer*> m_SendPostedQueue;
327
328 JNetSession(uint32 recvBuffSize);
329 void Init(SessionID id, SOCKET sock);
330 bool TryRelease();
331 };
332
333
337
338#pragma pack(push, 1)
345#pragma pack(pop)
346 void Encode(BYTE symmetricKey, BYTE randKey, USHORT payloadLen, BYTE& checkSum, BYTE* payloads);
347 bool Decode(BYTE symmetricKey, BYTE randKey, USHORT payloadLen, BYTE checkSum, BYTE* payloads);
348 bool Decode(BYTE symmetricKey, BYTE randKey, USHORT payloadLen, BYTE checkSum, JBuffer& ringPayloads);
350 return rand() % UINT8_MAX; // 0b0000'0000 ~ 0b0111'1110 (0b1111'1111은 디코딩이 이루어지지 않은 페이로드 식별 값)
351 }
352
353
354 /********************************************************************
355 * JNetServer
356 ********************************************************************/
363 class JNetServer : public JNetCore{
364 private:
365 SOCKADDR_IN m_ListenSockAddr;
367
370
372
374
375 protected:
379
380 public:
397 const char* serverIP, uint16 serverPort, uint16 maximumOfConnections,
398 PACKET_CODE packetCode_LAN, PACKET_CODE packetCode, PACKET_SYMM_KEY packetSymmetricKey,
399 bool recvBufferingMode,
400 uint16 maximumOfSessions,
401 uint32 numOfIocpConcurrentThrd, uint16 numOfIocpWorkerThrd,
402 size_t tlsMemPoolUnitCnt, size_t tlsMemPoolUnitCapacity,
403 uint32 memPoolBuffAllocSize,
404 uint32 sessionRecvBuffSize,
405 bool calcTpsThread
406 );
407 bool Start();
408 void Stop();
409
410 public:
412 system("cls"); // 콘솔 창 지우기
413 static size_t logCnt = 0;
414 static COORD coord;
415 coord.X = 0;
416 coord.Y = 0;
417 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
418
420 cout << "==========================================================" << endl;
422 }
423 protected:
424 virtual void OnPrintLogOnConsole() {}
425 private:
427
428 protected:
431 bool SendPacket(SessionID64 sessionID, JBuffer* sendPktPtr, bool postToWorker = false, bool encoded = false);
433 bool SendPacketBlocking(SessionID64 sessionID, JBuffer* sendPktPtr, bool encoded = false);
435 bool BufferSendPacket(SessionID64 sessionID, JBuffer* sendPktPtr, bool encoded = false);
436
440 inline JBuffer* AllocSerialSendBuff(uint16 len, bool LAN = false) {
441 JBuffer* msg = AllocSerialBuff();
442 stMSG_HDR* hdr = msg->DirectReserve<stMSG_HDR>();
443 if (!LAN) {
444 hdr->code = m_PacketCode;
445 }
446 else {
447 hdr->code = m_PacketCode_LAN;
448 }
449 hdr->len = len;
450 hdr->randKey = -1;
451
452 return msg;
453 }
454 protected:
458 virtual bool OnConnectionRequest(const SOCKADDR_IN& clientSockAddr)
459 {
461 return false;
462 }
463 else {
464 return true;
465 }
466 }
467
471 virtual void OnClientJoin(SessionID64 sessionID, const SOCKADDR_IN& clientSockAddr) = 0;
472
476 virtual void OnClientLeave(SessionID64 sessionID) = 0;
477
480 virtual void OnRecv(SessionID64 sessionID, JBuffer& recvBuff) {}
481
484 virtual void OnRecv(SessionID64 sessionID, JSerialBuffer& recvSerialBuff) {}
485
486 private:
487 virtual void OnRecvCompletion(SessionID64 sessionID, JBuffer& recvRingBuffer) override;
488 virtual void OnSessionLeave(SessionID64 sessionID) override {
489 InterlockedDecrement16(reinterpret_cast<short*>(&m_NumOfConnections));
490 OnClientLeave(sessionID);
491 }
492
493 private:
495 static UINT __stdcall AcceptThreadFunc(void* arg);
496 };
497
498 /********************************************************************
499 * JNetOdbcServer
500 ********************************************************************/
507 {
508 private:
510 const WCHAR* m_OdbcConnStr;
513
514 public:
516 int32 dbConnCnt, const WCHAR* odbcConnStr,
517 const char* serverIP, uint16 serverPort, uint16 maximumOfConnections,
518 PACKET_CODE packetCode_LAN, PACKET_CODE packetCode, PACKET_SYMM_KEY packetSymmetricKey,
519 bool recvBufferingMode,
520 uint16 maximumOfSessions,
521 uint32 numOfIocpConcurrentThrd, uint16 numOfIocpWorkerThrd,
522 size_t tlsMemPoolUnitCnt, size_t tlsMemPoolUnitCapacity,
523 uint32 memPoolBuffAllocSize,
524 uint32 sessionRecvBuffSize,
525 bool calcTpsThread
526 ) : JNetServer(serverIP, serverPort, maximumOfConnections,
527 packetCode_LAN, packetCode, packetSymmetricKey,
528 recvBufferingMode,
529 maximumOfSessions,
530 numOfIocpConcurrentThrd, numOfIocpWorkerThrd,
531 tlsMemPoolUnitCnt, tlsMemPoolUnitCapacity,
532 memPoolBuffAllocSize,
533 sessionRecvBuffSize,
534 calcTpsThread
535 ),
536 m_DBConnCnt(dbConnCnt), m_OdbcConnStr(odbcConnStr), m_DBConnFlag(false)
537 {}
538
539 bool Start();
540 void Stop();
541
542 protected:
544 inline void FreeDBConnection(JNetDBConn* dbConn, bool isDisconnected = false, bool tryToConnect = false) {
545 m_DBConnPool->Push(dbConn, isDisconnected, tryToConnect, m_OdbcConnStr);
546 }
547
548 bool BindParameter(JNetDBConn* dbConn, INT32 paramIndex, bool* value);
549 bool BindParameter(JNetDBConn* dbConn, INT32 paramIndex, float* value);
550 bool BindParameter(JNetDBConn* dbConn, INT32 paramIndex, double* value);
551 bool BindParameter(JNetDBConn* dbConn, INT32 paramIndex, INT8* value);
552 bool BindParameter(JNetDBConn* dbConn, INT32 paramIndex, INT16* value);
553 bool BindParameter(JNetDBConn* dbConn, INT32 paramIndex, INT32* value);
554 bool BindParameter(JNetDBConn* dbConn, INT32 paramIndex, INT64* value);
555 bool BindParameter(JNetDBConn* dbConn, INT32 paramIndex, TIMESTAMP_STRUCT* value);
556 bool BindParameter(JNetDBConn* dbConn, INT32 paramIndex, const WCHAR* str);
557 bool BindParameter(JNetDBConn* dbConn, INT32 paramIndex, const BYTE* bin, INT32 size);
558 bool BindColumn(JNetDBConn* dbConn, INT32 columnIndex, bool* value);
559 bool BindColumn(JNetDBConn* dbConn, INT32 columnIndex, float* value);
560 bool BindColumn(JNetDBConn* dbConn, INT32 columnIndex, double* value);
561 bool BindColumn(JNetDBConn* dbConn, INT32 columnIndex, INT8* value);
562 bool BindColumn(JNetDBConn* dbConn, INT32 columnIndex, INT16* value);
563 bool BindColumn(JNetDBConn* dbConn, INT32 columnIndex, INT32* value);
564 bool BindColumn(JNetDBConn* dbConn, INT32 columnIndex, INT64* value);
565 bool BindColumn(JNetDBConn* dbConn, INT32 columnIndex, TIMESTAMP_STRUCT* value);
566 bool BindColumn(JNetDBConn* dbConn, INT32 columnIndex, WCHAR* str, INT32 size, SQLLEN* index);
567 bool BindColumn(JNetDBConn* dbConn, INT32 columnIndex, BYTE* bin, INT32 size, SQLLEN* index);
568
569 bool BindParameter(JNetDBConn* dbConn, SQLPOINTER dataPtr, SQLUSMALLINT paramIndex, SQLULEN len, SQLSMALLINT cType, SQLSMALLINT sqlType);
570 bool BindColumn(JNetDBConn* dbConn, SQLPOINTER outValue, SQLUSMALLINT columnIndex, SQLULEN len, SQLSMALLINT cType);
571
572 void UnBind(JNetDBConn* dbConn);
573
574 bool ExecQuery(JNetDBConn* dbConn, const wchar_t* query);
575 bool FetchQuery(JNetDBConn* dbConn);
576 INT32 GetRowCount(JNetDBConn* dbConn);
577 };
578
579 /********************************************************************
580 * JNetClient
581 ********************************************************************/
587 class JNetClient : public JNetCore {
588 private:
591
592 const char* m_ServerIP;
594
596
597 public:
599 const char* serverIP, uint16 serverPort,
600 PACKET_CODE packetCode_LAN,
601 uint32 numOfIocpConcurrentThrd, uint16 numOfIocpWorkerThrd,
602 size_t tlsMemPoolUnitCnt, size_t tlsMemPoolUnitCapacity,
603 uint32 memPoolBuffAllocSize,
604 uint32 sessionRecvBuffSize,
605 bool calcTpsThread
606 )
607 : JNetCore(
608 1,
609 numOfIocpConcurrentThrd, numOfIocpWorkerThrd,
610 tlsMemPoolUnitCnt, tlsMemPoolUnitCapacity,
611 memPoolBuffAllocSize,
612 sessionRecvBuffSize,
613 calcTpsThread
614 ),
616 m_ServerIP(serverIP), m_ServerPort(serverPort),
617 m_PacketCode_LAN(packetCode_LAN)
618 {
619 cout << "JNetClient::JNetClient(..), Init JNetClient Done.." << endl;
620 }
621
622 bool Start(bool connectToServer = true);
623 void Stop();
624
625 protected:
626 bool ConnectToServer();
627
628 inline JBuffer* AllocSerialSendBuff(PACKET_LEN len) {
629 JBuffer* msg = JNetCore::AllocSerialBuff();
630 (*msg) << m_PacketCode_LAN;
631 (*msg) << len;
632
633 return msg;
634 }
635
636 bool SendPacket(JBuffer* sendPktPtr, bool postToWorker = false);
637 bool SendPacketBlocking(JBuffer* sendPktPtr);
638 bool BufferSendPacket(JBuffer* sendPktPtr);
639
640 protected:
641 virtual void OnConnectionToServer() = 0;
642 virtual void OnDisconnectionFromServer() = 0;
643 virtual void OnRecv(JBuffer& recvBuff) = 0;
644
645 private:
646 virtual void OnRecvCompletion(SessionID64 sessionID, JBuffer& recvRingBuffer) override;
647 virtual void OnSessionLeave(SessionID64 sessionID) override {
649 }
650 };
651
656 namespace jgroup {
658
659 class JNetGroupThread;
660
661 /********************************************************************
662 * JNetGroupServer
663 ********************************************************************/
671 {
672 friend class JNetGroupThread;
673
674 private:
675 std::unordered_map<SessionID64, GroupID> m_SessionGroupMap;
677
678 std::map<GroupID, JNetGroupThread*> m_GroupThreads;
679
680
681 public:
683 const char* serverIP, uint16 serverPort, uint16 maximumOfConnections,
684 BYTE packetCode_LAN, BYTE packetCode, BYTE packetSymmetricKey,
685 bool recvBufferingMode,
686 uint16 maximumOfSessions,
687 uint32 numOfIocpConcurrentThrd, uint16 numOfIocpWorkerThrd,
688 size_t tlsMemPoolUnitCnt, size_t tlsMemPoolUnitCapacity,
689 uint32 memPoolBuffAllocSize,
690 uint32 sessionRecvBuffSize,
691 bool calcTpsThread
692 ) : JNetServer(
693 serverIP, serverPort, maximumOfSessions,
694 packetCode_LAN, packetCode, packetSymmetricKey,
695 recvBufferingMode,
696 maximumOfSessions,
697 numOfIocpConcurrentThrd, numOfIocpWorkerThrd,
698 tlsMemPoolUnitCnt, tlsMemPoolUnitCapacity,
699 memPoolBuffAllocSize,
700 sessionRecvBuffSize,
701 calcTpsThread
702 )
703 {
704 InitializeSRWLock(&m_SessionGroupMapSrwLock);
705 cout << "JNetGroupServer::JNetGroupServer(..) Init JNetGroupServer.." << endl;
706 }
707
709 void CreateGroup(GroupID newGroupID, JNetGroupThread* groupThread, bool threadPriorBoost = false);
710 void DeleteGroup(GroupID delGroupID);
711
713 void EnterSessionGroup(SessionID64 sessionID, GroupID enterGroup);
714 void LeaveSessionGroup(SessionID64 sessionID);
716 void ForwardSessionGroup(SessionID64 sessionID, GroupID from, GroupID to);
717
719 void ForwardMessage(SessionID64 sessionID, JBuffer* msg);
721 void SendGroupMessage(GroupID from, GroupID to, JBuffer* groupMsg);
722
723 private:
724 virtual void OnRecv(SessionID64 sessionID, JSerialBuffer& recvSerialBuff) override;
725 virtual void OnRecv(SessionID64 sessionID, JBuffer& recvBuff) override;
726 };
727
728 /********************************************************************
729 * JNetGroupThread
730 ********************************************************************/
738 {
739 protected:
741 private:
745
748
761 LockFreeQueue<GroupTheradMessage> m_LockFreeMessageQueue;
762
763 private:
765 public:
767
768 public:
769 inline void Init(JNetGroupServer* server, GroupID groupID, bool threadPriorBoost = false, bool calcFps = false) {
770 m_Server = server;
771 m_GroupID = groupID;
772 m_PriorBoost = threadPriorBoost;
773 m_CalcFps = calcFps;
774 }
775 inline bool Start() {
776 m_GroupThreadStop = false;
777 m_GroupThreadHnd = (HANDLE)_beginthreadex(NULL, 0, SessionGroupThreadFunc, this, 0, NULL);
778 return true;
779 }
780 inline void Stop() {
781 m_GroupThreadStop = true;
782 }
783
784 inline void EnterSession(SessionID64 sessionID) {
785 m_LockFreeMessageQueue.Enqueue({ sessionID, enSessionEnter, NULL });
786 }
787 inline void LeaveSession(SessionID64 sessionID) {
788 m_LockFreeMessageQueue.Enqueue({ sessionID, enSessionLeave, NULL });
789 }
790 inline void PushSessionMessage(SessionID64 sessionID, JBuffer* msg) {
791 m_LockFreeMessageQueue.Enqueue({ sessionID, enSessionMessage, msg });
792 }
793 inline void PushGroupMessage(GroupID senderGroupID, JBuffer* msg) {
794 m_LockFreeMessageQueue.Enqueue({ senderGroupID, enGroupMessage, msg });
795 }
796
797 protected:
799
800 inline void Disconnect(SessionID64 sessionID) { m_Server->Disconnect(sessionID); }
801 inline bool SendPacket(SessionID64 sessionID, JBuffer* sendPktPtr, bool postToWorker = false, bool encoded = false) { return m_Server->SendPacket(sessionID, sendPktPtr, postToWorker, encoded); }
802 inline bool SendPacketBlocking(SessionID64 sessionID, JBuffer* sendPktPtr, bool encoded = false) { return m_Server->SendPacketBlocking(sessionID, sendPktPtr, encoded); }
803 inline bool BufferSendPacket(SessionID64 sessionID, JBuffer* sendPktPtr, bool encoded = false) { return m_Server->BufferSendPacket(sessionID, sendPktPtr, encoded); }
804 inline bool SendBufferedPacket(SessionID64 sessionID, bool postToWorker = false) { return m_Server->SendBufferedPacket(sessionID, postToWorker); }
805
806 inline void CreateGroup(GroupID newGroupID, JNetGroupThread* groupThread, bool threadPriorBoost = false) { m_Server->CreateGroup(newGroupID, groupThread, threadPriorBoost); }
807 inline void DeleteGroup(GroupID delGroupID) { m_Server->DeleteGroup(delGroupID); }
808 inline void ForwardSessionToGroup(SessionID64 sessionID, GroupID destGroup) { m_Server->ForwardSessionGroup(sessionID, m_GroupID, destGroup); }
809 inline void ForwardSessionMessage(SessionID64 sessionID, JBuffer* msg) { m_Server->ForwardMessage(sessionID, msg); }
810 inline void SendGroupMessage(GroupID groupID, JBuffer* msg) { m_Server->SendGroupMessage(m_GroupID, groupID, msg); }
811
812 inline DWORD AllocTlsMemPool() { return m_Server->AllocTlsMemPool(); }
813
814 inline JBuffer* AllocSerialBuff() { return m_Server->AllocSerialBuff(); }
815 inline JBuffer* AllocSerialSendBuff(uint16 len, bool LAN = false) { return m_Server->AllocSerialSendBuff(len, LAN); }
816 inline void FreeSerialBuff(JBuffer* buff) { m_Server->FreeSerialBuff(buff); }
817 inline void AddRefSerialBuff(JBuffer* buff) { m_Server->AddRefSerialBuff(buff); }
818
819 protected:
820 virtual void OnStart() {};
821 virtual void OnStop() {};
822 virtual void OnEnterClient(SessionID64 sessionID) = 0;
823 virtual void OnLeaveClient(SessionID64 sessionID) = 0;
824 virtual void OnMessage(SessionID64 sessionID, JBuffer& recvData) = 0;
825 virtual void OnGroupMessage(GroupID groupID, JBuffer& msg) = 0;
826
827 private:
828 static UINT __stdcall SessionGroupThreadFunc(void* arg);
829 };
830 }
831}
__int32 int32
Definition CommTypes.h:6
unsigned __int16 uint16
Definition CommTypes.h:9
unsigned char BYTE
Definition CommTypes.h:3
unsigned __int64 uint64
Definition CommTypes.h:11
unsigned __int32 uint32
Definition CommTypes.h:10
__int64 int64
Definition CommTypes.h:7
클라이언트 기능이 구체화된 'JNetCore' 하위 클래스, 동일 LAN 구간 서버로의 연결 요청과 패킷 송수신(ConnectToServer, OnRecv,...
Definition JNetCore.h:587
bool SendPacket(JBuffer *sendPktPtr, bool postToWorker=false)
Definition JNetClient.cpp:62
virtual void OnConnectionToServer()=0
SOCKET m_ConnectSock
클라이언트 연결 소켓
Definition JNetCore.h:589
JNetClient(const char *serverIP, uint16 serverPort, PACKET_CODE packetCode_LAN, uint32 numOfIocpConcurrentThrd, uint16 numOfIocpWorkerThrd, size_t tlsMemPoolUnitCnt, size_t tlsMemPoolUnitCapacity, uint32 memPoolBuffAllocSize, uint32 sessionRecvBuffSize, bool calcTpsThread)
Definition JNetCore.h:598
PACKET_CODE m_PacketCode_LAN
LAN 구간 패킷 코드
Definition JNetCore.h:595
bool ConnectToServer()
Definition JNetClient.cpp:28
bool BufferSendPacket(JBuffer *sendPktPtr)
Definition JNetClient.cpp:72
SessionID64 m_ServerSessionID64
연결 서버 세션 ID
Definition JNetCore.h:590
uint16 m_ServerPort
서버 Port
Definition JNetCore.h:593
bool SendPacketBlocking(JBuffer *sendPktPtr)
Definition JNetClient.cpp:67
virtual void OnSessionLeave(SessionID64 sessionID) override
JNetCore 단 세션이 제거된 후 호출되는 이벤트 함수
Definition JNetCore.h:647
JBuffer * AllocSerialSendBuff(PACKET_LEN len)
Definition JNetCore.h:628
void Stop()
Definition JNetClient.cpp:21
const char * m_ServerIP
서버 IP
Definition JNetCore.h:592
virtual void OnDisconnectionFromServer()=0
virtual void OnRecvCompletion(SessionID64 sessionID, JBuffer &recvRingBuffer) override
IOCP 작업자 스레드의 수신 완료 시 대상 세션의 수신 버퍼의 enqueue 오프셋 제어 후 호출되는 이벤트 함수
Definition JNetClient.cpp:77
virtual void OnRecv(JBuffer &recvBuff)=0
클라이언트 TCP 세션의 생명 주기를 'JNetSession'을 통해 관리하며, 하위 클래스 객체의 세션 접근(송신, 수신 처리 및 연결 종료)에 대한 thread-safe 성을 보...
Definition JNetCore.h:41
void SendPost(SessionID64 sessionID, bool onSendFlag=false)
SendPacket 계열 함수 내부에서 호출되는 실질적 송신 요청 함수
Definition JNetCore.cpp:360
bool SendPacketBlocking(SessionID64 sessionID, JBuffer *sendPktPtr)
동기식 송신 요청 함수
Definition JNetCore.cpp:177
void Stop()
Definition JNetCore.cpp:96
uint64 m_SessionIncrement
세션 증분 (SessionID's increment part)
Definition JNetCore.h:50
std::vector< JNetSession * > m_Sessions
세션 관리 벡터
Definition JNetCore.h:47
int GetSessionCount()
Definition JNetCore.h:157
void FreeSerialBuff(JBuffer *buff)
직렬화 패킷 버퍼 반환 wrapper
Definition JNetCore.h:144
TlsMemPoolManager< JBuffer, true, false > m_TlsMemPoolMgr
Tls 메모리 풀 관리 (직렬화 패킷 버퍼 풀 할당 및 관리자)
Definition JNetCore.h:57
UINT64 m_TotalTransaction[NUM_OF_TPS_ITEM]
Definition JNetCore.h:245
bool SendPacket(SessionID64 sessionID, JBuffer *sendPktPtr, bool postToWorker=false)
패킷 송신 요청 함수
Definition JNetCore.cpp:155
UINT GetAcceptTPS()
Definition JNetCore.h:248
virtual void OnRecvCompletion(SessionID64 sessionID, JBuffer &recvRingBuffer)=0
IOCP 작업자 스레드의 수신 완료 시 대상 세션의 수신 버퍼의 enqueue 오프셋 제어 후 호출되는 이벤트 함수
bool SendBufferedPacket(SessionID64 sessionID, bool postToWorker=false)
세션 송신 버퍼 큐 내 송신 패킷 직렬화 버퍼에 대한 일괄 송신 작업 수행
Definition JNetCore.cpp:217
void Proc_SendPostRequest(JNetSession *session)
IOCP 작업자 스레드의 송신 요청 시 처리 함수(SendPacket 계열 함수의 postToWorker 요청)
Definition JNetCore.cpp:624
JNetSession * AcquireSession(SessionID64 sessionID)
Multi IOCP 작업자 스레드 간 thread-safe 하지 않은 세션에 대해 세션 접근 전 호출하는 함수
Definition JNetCore.cpp:271
std::vector< HANDLE > m_IocpWorkerThrdHnds
IOCP 작업자 스레드 핸들 벡터
Definition JNetCore.h:54
UINT GetSendTPS()
Definition JNetCore.h:250
bool m_CalcTpsFlag
Definition JNetCore.h:230
virtual void OnAllWorkerThreadCreate()
Start() 함수 내 요청된 수 만큼 IOCP 작업자 스레드를 생성한 후 함수를 빠져나오기 전 호출되는 이벤트 함수
Definition JNetCore.cpp:243
void Proc_RecvCompletion(JNetSession *session, DWORD transferred)
IOCP 작업자 스레드의 수신 완료 통지 시 처리 함수
Definition JNetCore.cpp:646
virtual void OnError()
Definition JNetCore.cpp:261
bool Start()
Definition JNetCore.cpp:63
JBuffer * AllocSerialBuff()
직렬화 패킷 버퍼 할당 요청 wrapper
Definition JNetCore.h:137
UINT m_TransactionsPerSecond[NUM_OF_TPS_ITEM]
Definition JNetCore.h:244
JNetCore(uint16 maximumOfSessions, uint32 numOfIocpConcurrentThrd, uint16 numOfIocpWorkerThrd, size_t tlsMemPoolUnitCnt, size_t tlsMemPoolUnitCapacity, uint32 memPoolBuffAllocSize, uint32 sessionRecvBuffSize, bool calcTpsThread)
Definition JNetCore.cpp:5
UINT64 GetTotalSendTransaction()
Definition JNetCore.h:253
static const int NUM_OF_TPS_ITEM
Definition JNetCore.h:233
uint32 m_MemPoolBuffAllocSize
Definition JNetCore.h:61
void AddRefSerialBuff(JBuffer *buff)
직렬화 패킷 버퍼 참조 카운트 증가 wrapper
Definition JNetCore.h:149
uint16 m_MaximumOfSessions
수용 가능한 최대 세션 수
Definition JNetCore.h:48
int64 GetCurrentAllocatedMemUnitCnt()
Definition JNetCore.h:154
bool DeleteSession(SessionID64 sessionID)
세션 제거 요청 함수
Definition JNetCore.cpp:488
HANDLE m_IOCP
JNetCore's IOCP 객체
Definition JNetCore.h:52
UINT GetRecvTPS()
Definition JNetCore.h:249
UINT64 GetTotalRecvTransaction()
Definition JNetCore.h:252
void IncrementRecvTransactions(bool threadSafe, UINT incre)
Definition JNetCore.h:255
void Proc_DeleteSession(JNetSession *session)
IOCP 작업자 스레드의 세션 삭제 요청 처리 함수
Definition JNetCore.cpp:603
void IncrementAcceptTransactions(bool threadSafe=false, UINT incre=1)
Definition JNetCore.h:257
uint16 GetCurrentSessions()
Definition JNetCore.h:84
virtual void OnSessionLeave(SessionID64 sessionID)
JNetCore 단 세션이 제거된 후 호출되는 이벤트 함수
Definition JNetCore.cpp:259
enTransaction
Definition JNetCore.h:234
@ SEND_TRANSACTION
Definition JNetCore.h:237
@ RECV_TRANSACTION
Definition JNetCore.h:236
@ ACCEPT_TRANSACTION
Definition JNetCore.h:235
@ SEND_REQ_TRANSACTION
Definition JNetCore.h:238
virtual void OnWorkerThreadStart()
개별 IOCP 작업자 스레드의 수행 흐름 초입부(WorkerThreadFunc 함수 초입부)에 호출되는 이벤트 함수, 개별 작업자 스레드의 초기화를 독립적으로 수행하도록 재정의 가능
Definition JNetCore.cpp:250
void FreeBufferedSendPacket(LockFreeQueue< JBuffer * > &sendBufferQueue, queue< JBuffer * > &sendPostedQueue)
세션 제거 시 송신 버퍼 정리
Definition JNetCore.cpp:524
void IncrementTransactions(BYTE type, bool threadSafe=false, UINT incre=1)
Definition JNetCore.h:260
size_t m_TlsMemPoolUnitCnt
Definition JNetCore.h:59
UINT m_Transactions[NUM_OF_TPS_ITEM]
Definition JNetCore.h:243
~JNetCore()
Definition JNetCore.cpp:56
uint16 m_NumOfIocpWorkerThrd
IOCP 작업자 스레드 갯수
Definition JNetCore.h:53
void IncrementSendTransactions(bool threadSafe, UINT incre)
Definition JNetCore.h:256
size_t m_TlsMemPoolUnitCapacity
Definition JNetCore.h:60
bool BufferSendPacket(SessionID64 sessionID, JBuffer *sendPktPtr)
세션 송신 버퍼 큐에 버퍼링(삽입만 진행)
Definition JNetCore.cpp:202
LockFreeQueue< uint16 > m_SessionIndexQueue
세션 인덱스 할당 큐 (SessionID's index part)
Definition JNetCore.h:49
void PrintLibraryInfoOnConsole()
Definition JNetCore.cpp:112
static UINT __stdcall CalcTpsThreadFunc(void *arg)
Definition JNetCore.cpp:716
LONG GetTransactionsPerSecond(BYTE type)
Definition JNetCore.h:269
JNetSession * CreateNewSession(SOCKET sock)
하위 클래스에서 세션 객체 생성 요청을 위해 호출하는 함수
Definition JNetCore.cpp:443
void ReturnSession(JNetSession *session)
AcquireSession을 통해 획득한 세션 객체 소유권 반납
Definition JNetCore.cpp:330
virtual void OnWorkerThreadEnd()
개별 IOCP 작업자 스레드가 종료(작업자 함수 return) 전 호출되는 이벤트 함수
Definition JNetCore.cpp:252
static UINT __stdcall WorkerThreadFunc(void *arg)
IOCP 작업자 스레드의 수행 함수
Definition JNetCore.cpp:539
HANDLE m_CalcTpsThread
Definition JNetCore.h:241
DWORD AllocTlsMemPool()
직렬화 패킷 버퍼 Tls 풀 할당 함수
Definition JNetCore.h:132
void SendPostRequest(SessionID64 sessionID)
SendPost() 함수의 작업을 IOCP 작업자 스레드의 흐름에서 수행되도록 강제화를 요청하는 함수
Definition JNetCore.cpp:432
UINT64 GetTotalAcceptTransaction()
Definition JNetCore.h:251
bool RegistSessionToIOCP(JNetSession *session)
하위 클래스에서 세션 객체를 IOCP 등록을 위해 호출하는 함수
Definition JNetCore.cpp:456
void Disconnect(SessionID64 sessionID)
Definition JNetCore.cpp:142
void Proc_SendCompletion(JNetSession *session)
IOCP 작업자 스레드의 송신 완료 통지 시 처리 함수
Definition JNetCore.cpp:690
UINT64 GetTotalTransactions(BYTE type)
Definition JNetCore.h:270
std::vector< uint32 > m_IocpWorkerThrdIDs
IOCP 작업자 스레드's ID 벡터
Definition JNetCore.h:55
virtual bool OnWorkerThreadCreate(HANDLE thHnd)
Start() 함수 내 IOCP 작업자 스레드 생성(CREATE_SUSPENDED) 후 호출되는 이벤트 함수
Definition JNetCore.cpp:241
DB 커넥션 인스턴스 Pool
Definition JNetDB.h:109
void Push(JNetDBConn *connection, bool isDisconnected=false, bool tryToConnect=false, const WCHAR *connectionString=NULL)
Definition JNetDB.cpp:525
JNetDBConn * Pop()
Definition JNetDB.cpp:510
DB Connection 추상화
Definition JNetDB.h:17
DB 커넥션 기능을 수행하는 DB 커넥션 객체 풀을 관리하여 커넥션(HoldConnection)과 SQL 쿼리 및 응답 처리(ExecQuery, FetchQuery) 추상화 제공
Definition JNetCore.h:507
void FreeDBConnection(JNetDBConn *dbConn, bool isDisconnected=false, bool tryToConnect=false)
Definition JNetCore.h:544
JNetDBConnPool * m_DBConnPool
DB Connection Pool
Definition JNetCore.h:511
bool ExecQuery(JNetDBConn *dbConn, const wchar_t *query)
Definition JNetOdbcServer.cpp:197
void Stop()
Definition JNetOdbcServer.cpp:22
bool BindParameter(JNetDBConn *dbConn, INT32 paramIndex, bool *value)
Definition JNetOdbcServer.cpp:32
const WCHAR * m_OdbcConnStr
ODBC Connection String
Definition JNetCore.h:510
JNetDBConn * HoldDBConnection()
Definition JNetCore.h:543
bool m_DBConnFlag
Definition JNetCore.h:512
void UnBind(JNetDBConn *dbConn)
Definition JNetOdbcServer.cpp:190
bool BindColumn(JNetDBConn *dbConn, INT32 columnIndex, bool *value)
Definition JNetOdbcServer.cpp:102
bool FetchQuery(JNetDBConn *dbConn)
Definition JNetOdbcServer.cpp:205
bool Start()
Definition JNetOdbcServer.cpp:5
JNetOdbcServer(int32 dbConnCnt, const WCHAR *odbcConnStr, const char *serverIP, uint16 serverPort, uint16 maximumOfConnections, PACKET_CODE packetCode_LAN, PACKET_CODE packetCode, PACKET_SYMM_KEY packetSymmetricKey, bool recvBufferingMode, uint16 maximumOfSessions, uint32 numOfIocpConcurrentThrd, uint16 numOfIocpWorkerThrd, size_t tlsMemPoolUnitCnt, size_t tlsMemPoolUnitCapacity, uint32 memPoolBuffAllocSize, uint32 sessionRecvBuffSize, bool calcTpsThread)
Definition JNetCore.h:515
INT32 GetRowCount(JNetDBConn *dbConn)
Definition JNetOdbcServer.cpp:214
int32 m_DBConnCnt
DB Connection Count
Definition JNetCore.h:509
서버 기능이 구체화된 'JNetCore' 하위 클래스, 클라이언트와의 연결 완료 시 '세션 객체 생성' 및 'IOCP 객체에 소켓 장치 등록' 수행 패킷 수신 완료 시의 이벤트 ...
Definition JNetCore.h:363
SOCKADDR_IN m_ListenSockAddr
서버 바인딩 주소
Definition JNetCore.h:365
static UINT __stdcall AcceptThreadFunc(void *arg)
Accept 스레드의 수행 함수
Definition JNetServer.cpp:243
JBuffer * AllocSerialSendBuff(uint16 len, bool LAN=false)
직렬화 패킷 버퍼 할당 + 헤더 초기화
Definition JNetCore.h:440
virtual void OnSessionLeave(SessionID64 sessionID) override
JNetCore 단 세션이 제거된 후 호출되는 이벤트 함수
Definition JNetCore.h:488
virtual bool OnConnectionRequest(const SOCKADDR_IN &clientSockAddr)
Accept 반환 시 호출되는 이벤트 함수, 클라이언트 수용 여부를 반환을 통해 결정
Definition JNetCore.h:458
void PrintLibraryInfoOnConsole()
Definition JNetServer.cpp:80
virtual void OnRecvCompletion(SessionID64 sessionID, JBuffer &recvRingBuffer) override
IOCP 작업자 스레드의 수신 완료 시 대상 세션의 수신 버퍼의 enqueue 오프셋 제어 후 호출되는 이벤트 함수
Definition JNetServer.cpp:144
bool SendPacket(SessionID64 sessionID, JBuffer *sendPktPtr, bool postToWorker=false, bool encoded=false)
JNetCore 요청 함수 + 송신 패킷 인코딩 기능
Definition JNetServer.cpp:87
SOCKET m_ListenSock
서버 리슨 소켓
Definition JNetCore.h:366
uint16 m_NumOfConnections
현재 연결된 연결 수
Definition JNetCore.h:369
virtual void OnPrintLogOnConsole()
Definition JNetCore.h:424
virtual void OnRecv(SessionID64 sessionID, JBuffer &recvBuff)
패킷 수신 시 호출되는 이벤트 함수
Definition JNetCore.h:480
uint16 m_MaximumOfConnections
수용 가능한 최대 연결 수
Definition JNetCore.h:368
JNetServer(const char *serverIP, uint16 serverPort, uint16 maximumOfConnections, PACKET_CODE packetCode_LAN, PACKET_CODE packetCode, PACKET_SYMM_KEY packetSymmetricKey, bool recvBufferingMode, uint16 maximumOfSessions, uint32 numOfIocpConcurrentThrd, uint16 numOfIocpWorkerThrd, size_t tlsMemPoolUnitCnt, size_t tlsMemPoolUnitCapacity, uint32 memPoolBuffAllocSize, uint32 sessionRecvBuffSize, bool calcTpsThread)
Definition JNetServer.cpp:5
virtual void OnClientLeave(SessionID64 sessionID)=0
클라이언트와의 연결 종료 및 클라이언트 세션 제거 후 호출되는 이벤트 함수
bool BufferSendPacket(SessionID64 sessionID, JBuffer *sendPktPtr, bool encoded=false)
Definition JNetServer.cpp:125
void Stop()
Definition JNetServer.cpp:74
bool SendPacketBlocking(SessionID64 sessionID, JBuffer *sendPktPtr, bool encoded=false)
Definition JNetServer.cpp:106
void PrintServerInfoOnConsole()
Definition JNetCore.h:411
BYTE m_PacketCode
LAN 외부 통신 패킷 코드
Definition JNetCore.h:377
HANDLE m_AcceptThreadHnd
Accept 스레드 핸들
Definition JNetCore.h:371
bool m_RecvBufferingMode
수신 버퍼링 모드 플래그
Definition JNetCore.h:373
BYTE m_PacketCode_LAN
LAN 구간 패킷 코드
Definition JNetCore.h:376
bool Start()
Definition JNetServer.cpp:36
virtual void OnClientJoin(SessionID64 sessionID, const SOCKADDR_IN &clientSockAddr)=0
클라이언트 연결 수용 후 정상적으로 세션을 생성한 이 후 호출되는 이벤트 함수
BYTE m_PacketSymmetricKey
대칭-키
Definition JNetCore.h:378
virtual void OnRecv(SessionID64 sessionID, JSerialBuffer &recvSerialBuff)
패킷 수신 시 호출되는 이벤트 함수, 수신 버퍼링 모드의 서버 전용
Definition JNetCore.h:484
클라이언트 세션을 그룹 단위로 묶고, 'JNetGroupThread' 인스턴스의 메시지 큐(그룹 메시지 큐)에 전달 '그룹 생성', '세션의 그룹 이동',...
Definition JNetCore.h:671
void ForwardSessionGroup(SessionID64 sessionID, GroupID from, GroupID to)
세션의 그룹 이동
Definition JNetGroup.cpp:49
void CreateGroup(GroupID newGroupID, JNetGroupThread *groupThread, bool threadPriorBoost=false)
그룹 생성 (그룹 식별자 반환, 라이브러리와 컨텐츠는 그룹 식별자를 통해 식별)
Definition JNetGroup.cpp:7
void LeaveSessionGroup(SessionID64 sessionID)
Definition JNetGroup.cpp:37
std::map< GroupID, JNetGroupThread * > m_GroupThreads
그룹-그룹 스레드 맵핑
Definition JNetCore.h:678
void SendGroupMessage(GroupID from, GroupID to, JBuffer *groupMsg)
그룹 간 메시지 송신
Definition JNetGroup.cpp:74
std::unordered_map< SessionID64, GroupID > m_SessionGroupMap
세션-그룹 맵핑
Definition JNetCore.h:675
JNetGroupServer(const char *serverIP, uint16 serverPort, uint16 maximumOfConnections, BYTE packetCode_LAN, BYTE packetCode, BYTE packetSymmetricKey, bool recvBufferingMode, uint16 maximumOfSessions, uint32 numOfIocpConcurrentThrd, uint16 numOfIocpWorkerThrd, size_t tlsMemPoolUnitCnt, size_t tlsMemPoolUnitCapacity, uint32 memPoolBuffAllocSize, uint32 sessionRecvBuffSize, bool calcTpsThread)
Definition JNetCore.h:682
virtual void OnRecv(SessionID64 sessionID, JSerialBuffer &recvSerialBuff) override
패킷 수신 시 호출되는 이벤트 함수, 수신 버퍼링 모드의 서버 전용
Definition JNetGroup.cpp:81
void DeleteGroup(GroupID delGroupID)
Definition JNetGroup.cpp:15
void ForwardMessage(SessionID64 sessionID, JBuffer *msg)
세션 수신 메시지 포워딩
Definition JNetGroup.cpp:61
SRWLOCK m_SessionGroupMapSrwLock
Definition JNetCore.h:676
void EnterSessionGroup(SessionID64 sessionID, GroupID enterGroup)
세션의 특정 그룹 입장
Definition JNetGroup.cpp:26
'JNetGroupServer' 인스턴스로부터 그룹 메시지 큐에 전달된 메시지를 싱글 스레드가 수신하여 메시지 처리 콜백을 호출 단일 세션에 대한 수신 직렬 처리를 보장하며,...
Definition JNetCore.h:738
void FreeSerialBuff(JBuffer *buff)
Definition JNetCore.h:816
JNetGroupServer * m_Server
Definition JNetCore.h:740
void Init(JNetGroupServer *server, GroupID groupID, bool threadPriorBoost=false, bool calcFps=false)
Definition JNetCore.h:769
void SendGroupMessage(GroupID groupID, JBuffer *msg)
Definition JNetCore.h:810
virtual void OnLeaveClient(SessionID64 sessionID)=0
int m_GroupThreadProcFPS
Definition JNetCore.h:764
bool SendBufferedPacket(SessionID64 sessionID, bool postToWorker=false)
Definition JNetCore.h:804
void PushSessionMessage(SessionID64 sessionID, JBuffer *msg)
Definition JNetCore.h:790
void CreateGroup(GroupID newGroupID, JNetGroupThread *groupThread, bool threadPriorBoost=false)
Definition JNetCore.h:806
void ForwardSessionMessage(SessionID64 sessionID, JBuffer *msg)
Definition JNetCore.h:809
virtual void OnStart()
Definition JNetCore.h:820
void PushGroupMessage(GroupID senderGroupID, JBuffer *msg)
Definition JNetCore.h:793
int GetGroupThreadLoopFPS()
Definition JNetCore.h:766
virtual void OnEnterClient(SessionID64 sessionID)=0
JBuffer * AllocSerialSendBuff(uint16 len, bool LAN=false)
Definition JNetCore.h:815
bool SendPacket(SessionID64 sessionID, JBuffer *sendPktPtr, bool postToWorker=false, bool encoded=false)
Definition JNetCore.h:801
DWORD AllocTlsMemPool()
Definition JNetCore.h:812
void Disconnect(SessionID64 sessionID)
Definition JNetCore.h:800
static UINT __stdcall SessionGroupThreadFunc(void *arg)
Definition JNetGroup.cpp:121
HANDLE m_GroupThreadHnd
그룹 스레드 핸들
Definition JNetCore.h:746
void DeleteGroup(GroupID delGroupID)
Definition JNetCore.h:807
JBuffer * AllocSerialBuff()
Definition JNetCore.h:814
bool Start()
Definition JNetCore.h:775
bool m_CalcFps
그룹 스레드의 FPS(Framge per second) 측정 여부 플래그
Definition JNetCore.h:744
bool SendPacketBlocking(SessionID64 sessionID, JBuffer *sendPktPtr, bool encoded=false)
Definition JNetCore.h:802
bool m_GroupThreadStop
그룹 스레드 중지 플래그
Definition JNetCore.h:747
GroupTheradMessageType
Definition JNetCore.h:755
@ enSessionLeave
Definition JNetCore.h:757
@ enSessionMessage
Definition JNetCore.h:758
@ enSessionEnter
Definition JNetCore.h:756
@ enGroupMessage
Definition JNetCore.h:759
virtual void OnGroupMessage(GroupID groupID, JBuffer &msg)=0
void AddRefSerialBuff(JBuffer *buff)
Definition JNetCore.h:817
void Stop()
Definition JNetCore.h:780
LockFreeQueue< GroupTheradMessage > m_LockFreeMessageQueue
Definition JNetCore.h:761
bool m_PriorBoost
그룹 스레드의 우선순위 부스팅 여부 플래그
Definition JNetCore.h:743
GroupID GetGroupID()
Definition JNetCore.h:798
void LeaveSession(SessionID64 sessionID)
Definition JNetCore.h:787
GroupID m_GroupID
그룹 스레드 인스턴스의 관리 대상인 그룹 ID
Definition JNetCore.h:742
virtual void OnMessage(SessionID64 sessionID, JBuffer &recvData)=0
void EnterSession(SessionID64 sessionID)
Definition JNetCore.h:784
void ForwardSessionToGroup(SessionID64 sessionID, GroupID destGroup)
Definition JNetCore.h:808
bool BufferSendPacket(SessionID64 sessionID, JBuffer *sendPktPtr, bool encoded=false)
Definition JNetCore.h:803
virtual void OnStop()
Definition JNetCore.h:821
JNetGroupServer/JNetGroupThread class
uint16 GroupID
Definition JNetCore.h:657
JNetCore/JNetServer/JNetOdbcServer/JNetClient class
uint16 PACKET_LEN
Definition JNetCore.h:336
bool Decode(BYTE symmetricKey, BYTE randKey, USHORT payloadLen, BYTE checkSum, BYTE *payloads)
Definition JNetEncryption.cpp:25
void Encode(BYTE symmetricKey, BYTE randKey, USHORT payloadLen, BYTE &checkSum, BYTE *payloads)
Definition JNetEncryption.cpp:3
BYTE GetRandomKey()
Definition JNetCore.h:349
BYTE PACKET_SYMM_KEY
Definition JNetCore.h:335
BYTE PACKET_CODE
Definition JNetCore.h:334
uint64 SessionID64
Definition JNetCore.h:28
세션 ID 비트 필드
Definition JNetCore.h:280
uint64 idx
Definition JNetCore.h:281
SessionID(SessionID64 id64)
Definition JNetCore.h:285
SessionID()
Definition JNetCore.h:284
SessionID(uint64 allocIdx, uint64 allocIncre)
Definition JNetCore.h:288
uint64 increment
Definition JNetCore.h:282
세션 참조 제어용 비트 필드
Definition JNetCore.h:299
SessionRef(int32 ref, int32 flag)
Definition JNetCore.h:307
SessionRef(int32 ref32)
Definition JNetCore.h:304
int32 refCnt
Definition JNetCore.h:300
SessionRef & operator=(int32 ref32)
Definition JNetCore.h:309
SessionRef()
Definition JNetCore.h:303
int32 releaseFlag
Definition JNetCore.h:301
JNetCore에서 관리되는 세션 구조체 세션의 연결 소켓 및 수신 링-버퍼와 송신 락-프리 큐 버퍼를 멤버로 갖으며, 세션 ID와 참조 카운트 필드를 바탕으로 thread-sa...
Definition JNetCore.h:278
LockFreeQueue< JBuffer * > m_SendBufferQueue
Definition JNetCore.h:325
WSAOVERLAPPED m_SendOverlapped
Definition JNetCore.h:323
SOCKET m_Sock
Definition JNetCore.h:321
WSAOVERLAPPED m_RecvOverlapped
Definition JNetCore.h:322
int32 m_SendFlag
Definition JNetCore.h:319
SessionID m_ID
Definition JNetCore.h:317
SessionRef m_SessionRef
Definition JNetCore.h:318
JBuffer m_RecvRingBuffer
Definition JNetCore.h:324
bool TryRelease()
Definition JNetSession.cpp:35
void Init(SessionID id, SOCKET sock)
Definition JNetSession.cpp:9
JNetSession(uint32 recvBuffSize)
Definition JNetSession.cpp:5
queue< JBuffer * > m_SendPostedQueue
Definition JNetCore.h:326
그룹 스레드에 전달되는 메시지 구조체
Definition JNetCore.h:750
JBuffer * msgPtr
Definition JNetCore.h:753
UINT64 msgSenderID
Definition JNetCore.h:751
Definition JNetCore.h:339
BYTE code
Definition JNetCore.h:340
BYTE randKey
Definition JNetCore.h:342
uint16 len
Definition JNetCore.h:341
BYTE checkSum
Definition JNetCore.h:343