Caloris is a simple Win32 client library for Socket.IO, without Boost::Asio. Boost::Asio is most powerful library, but Asio's IOCP model have too many thread on client side. So, Caloris select WSAEventSelect model.
Socket.IO is a module of node.js that base on RFC6455, but modified. I was analyzed Socket.IO's TCP packet and write packet code on C/C++. See more http://rhea.pe.kr/515.
Caloris's socket model is WSAEventSelect. This is an asynchronous I/O and very fast. I like WSAEventSelect on client side. See more
[http://msdn.microsoft.com/en-us/library/windows/desktop/ms741576(v=vs.85).aspx](http://msdn.microsoft.com/en-us/library/windows/desktop/ms741576(v=vs.85).
I am developing an MMORPG. When I need community module, I select the Socket.IO. But there is not Socket.IO's C++ client that make write Caloris.
To be continued...
[[todo]]
- 불필요한 boost 헤더 include 제거, OutputDebugStringA를 ATLTACE로 수정
- 서버가 죽어 있을 때, Connect를 하면 테스트 프로그램이 블럭킹된다. ( Connecton 알림 메시지를 PostMessage로 변경하면 해결됨 )
- 알림 윈도우 핸들 HWND* 일 필요가 없음 HWND로 수정
- 연결을 종료할 때 Heaert beat Send Thread가 죽지 않는다 . Heaert beat 쓰레드에서 Caloris 포인터를 가지고 있지만 이미 free된 객체이므로 엑세스 에러를 일으킬수 있다. 소멸자에서 TerminateThread해 줄것
- 메시지를 인코딩하는데 args를 약간의 오류가 있을 수 있다. 꼭 string 타입으로 전환할 필요가 없다. 예제는 채팅이었기 때문에 스트링으로 타입을 변경한 후 전송한 듯하다. 복잡한 프로토콜로 전달하려면 json 객체를 파라미터로 전달 할 수 있도록 수정 필요
- json 파싱시 예외가 발생할 수 있다. 실제로 테스트시 예외가 발생해서 exe가 종료되었음 try catch로 jsaon파싱부분은 묶어줄 필요가 있음
사이즈가 8바이트 크기를 처리할 경우 Node에서 파싱에러가 나서 소켓을 끊는 문제가 있다.
char frame[20] = {0,}; //===> frame 헤더의 최대 크기는 10인데 기존에는 8로 되어 있어서 스택깨지는 문제, 비정상 종료
frame[0] = opcode;
frame[1] = secondByte;
switch(secondByte)
{
case 126:
{
frame[2] = dataLength>>8;
frame[3] = dataLength%256;
}break;
case 127:
{
size_t temp = dataLength;
for( int i = 0; i<8; ++i)
{
frame[startOffset-i-1] = temp & 0xff; //===> -1이 아니라 -i-1 임 (사이즈 설정 오류 수정 )
temp = temp >> 8; // temp >>>= 8
}
}
}
`
m_rgxDecode = "([^:]+):([0-9]+)?[\+]?:([^:]+)?:?(.+)?"; // \를 \\로 수정해야 되는거 아닌가? 컴파일 워닝이 뜨는데??
