moai/moai-dev — pull request #819 by quocble (2014-01-14 06:47:04+00:00)
Title: websocket implementation

I integrated with websocketpp for a few reasons. It is C++, async, clean API, and well tested against websocket specs. It also includes boost library (need some cleanup). There are some pre-built (FAT) library like boost_system, and boost_random, which is required to compile with websocketpp. The sample includes the python server tornado which is very scalable, and lua example below.

Example usage:
```
ws = MOAIWebSocket.new()

function onMessageReceived( msg )
print("WebSocket: " .. msg )
end

function onConnected( msg )
print("WebSocket: " .. msg )
ws:write("Hello")
ws:write("help")
end

function onClosed( msg )
print("WebSocket: " .. msg )
end

function onFailed( msg )
print("WebSocket: " .. msg )
end

ws:setListener ( MOAIWebSocket.ON_MESSAGE, onMessageReceived )
ws:setListener ( MOAIWebSocket.ON_CONNECT, onConnected )
ws:setListener ( MOAIWebSocket.ON_CLOSE, onClosed )
ws:setListener ( MOAIWebSocket.ON_FAIL, onFailed )

ws:start("ws://10.41.18.247:8080/ws")
```