Skip to content

Caloris is a part of Mercury project. The simple and fast(asynchronous) Win32 C++ library for Socket.IO or websocket server.

Notifications You must be signed in to change notification settings

dajkim76/Caloris

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Caloris

What is Caloris?

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.

Websocket protocol

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.

Socket.IO protocol

WSAEventSelect

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).

Why Caloris?

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.

Enjoy WebScoket: node.js + Socket.IO + Caloris

To be continued...

asio를 이용한 거지같은 라이브러리보다 100배는 간결하고 잘 동작하는 라이브러리임 굿

[[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]+)?[\+]?:([^:]+)?:?(.+)?"; // \를 \\로 수정해야 되는거 아닌가? 컴파일 워닝이 뜨는데??

About

Caloris is a part of Mercury project. The simple and fast(asynchronous) Win32 C++ library for Socket.IO or websocket server.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 95.8%
  • C 2.2%
  • Objective-C 1.2%
  • JavaScript 0.8%