forked from nowelium/socket.io-titanium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
90 lines (72 loc) · 1.97 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
socket.io-titanium
------------------
socket.io@0.9.1-1(socket.io-client@0.9.1-1)
TiMob SDK 1.8.1
How to use
==========
* run server(chat server)
shell > node prj/example-nodejs-server/chat.js
* client(chat client)
* DIR
prj/
- README
- LICENSE
- tiapp.xml
- example-nodejs-server/
- server.js
- chat.js
- Resources/
- app.js
- socket.io-titanium.js
- ti-websocket-client/
- ti-websocket-client.js
- socket.io/
- package.json
- lib/
- io.js
- socket.js
- util.js
- transport.js
- transports/
- xhr.js
- xhr-polling.js
- ...
Example
=======
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);
});
Notes
=====
* 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
<property name="ti.android.threadstacksize" type="int">32768</property>