TiWS Connector is simple module that extends the functionality of iamyellow TiWS native module (https://github.com/iamyellow/tiws).
It adds reconnecting functionality, and even more fun.
Download the latest distribution ZIP-file and consult the Titanium Documentation on how install it, or simply use the gitTio CLI:
$ gittio install tiws.extended
TiWs: https://github.com/iamyellow/tiws Ti.mely: https://github.com/benbahrenburg/ti.mely
Starts Websocket connection, and adds its Events Listeners, and you can access the Websocket object using
socketHandler.websocket;
You can use this to send any message to the server, the message param takes any kind of data that can be sent over web socket connection.
Closes the Websocket connection.
Enables the reconnection option in your websocket app.
Fires disconnected event, and attempts the reconnection.
Checks the messaging status, and confirms that you're recieving data.
Sets the max time the client should be waiting for data before it goes into reconnecting mode. Default is 10 seconds.
The following Events can be handeled easily using Ti.App.addEventListener.
Event fired when connection to a websocket is completed.
Event fired when you get disconnected from websocket.
Event fired when you get attempt to reconnect to the websocket.
Event fired when you recieve websocket message.
Handeled like this:
Ti.App.addEventListener("websocketMessage", function(e) {
Ti.API.log(e.event.data);
});
You can listen to those events by adding Event Listener to the Proprity socketHandler.websocket