socket.io@0.9.1-1(socket.io-client@0.9.1-1) TiMob SDK 1.8.1
run server(chat server)
shell > node prj/example-nodejs-server/chat.js
client(chat client)
channel chat titanium example: Resources/win_ti.js channel chat server example: example-nodejs-server/chat.js
va io = require('socket.io-titanium');
var socket = io.connect('169.254.10.100:8080');
var chat = socket.of('/chat');
chat.on('available_channel', function (channels){
channels.forEach(function (channelName){
var row = Ti.UI.createTableViewRow({ title: channelName });
...
});
...
});
chat.on('broadcat:message', function(message){
....
});
input.addEventListener('return', function(){
chat.emit('post', input.value);
});
win.addEventListener('open', function(){
chat.emit('join:channel', channelId);
});
Mac OSX
run with iphonesim or android: set localnetwork alias localhost(127.0.0.1)::
shell > sudo ifconfig lo0 alias 169.254.10.100 netmask 0xffffff
run iphonesimlator..
[js code] var socket = io.connect('169.254.10.100:8080'); socket.send('hello world!!'); socket.on('message', function (message){ ... });
android client: add property tiapp.xml