socket.io-titanium
socket.io-titanium copied to clipboard
Script Error = 'undefined' is not a function (evaluating 'obj.otherwise()')
Hi everytime i run the code i get the following issues
[ERROR] Script Error = 'undefined' is not a function (evaluating 'obj.otherwise()') (unknown file)
2012-08-20 09:15:29.483 socketio.titanium[4170:1b50b] *** Terminating app due to uncaught exception of class '__NSCFDictionary'
terminate called throwing an exception
[INFO] Application has exited from Simulator
Can someone tell me what this might be thanks
Hi.
I had a similar problem ( maybe the exact same problem ) when i tried the example app using the iPad simulator.
Turns out the IOS version is only included if You are running it on an iPhone.
Try changing the regex in the third line of the "Resources / socket.io-titanium.js" from /iphone/ to /iphone|ipad/ which will also match the iPad.
;-) René
Hi Rene Thanks for the response
Can you please take me through setting up the environment to work for me i am doing the following.
i have installed node http://nodejs.org/ with the package manager so i have node and npm installed correctly then i import your github project into titanium so i have all the files their.
i cd into to example-nodejs-server
cd example-nodejs-server/
then i run the command to fire up the node server with socket.io
node chat.js
and i get the following output
module.js:340
throw err;
^
Error: Cannot find module 'socket.io-client'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/Users/samueleast/Documents/Titanium_Studio_Workspace/socket.io-titanium/example-nodejs-server/node_modules/socket.io/lib/socket.io.js:12:14)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
ok soo it Cannot find module 'socket.io-client' ?
so i have tried the following
sudo npm install socket.io-client
And i get the following
Password:
npm http GET https://registry.npmjs.org/socket.io-client
npm http 304 https://registry.npmjs.org/socket.io-client
npm http GET https://registry.npmjs.org/uglify-js/1.2.5
npm http GET https://registry.npmjs.org/ws
npm http GET https://registry.npmjs.org/xmlhttprequest/1.4.2
npm http GET https://registry.npmjs.org/active-x-obfuscator/0.0.1
npm http 304 https://registry.npmjs.org/ws
npm http 304 https://registry.npmjs.org/uglify-js/1.2.5
npm http 304 https://registry.npmjs.org/active-x-obfuscator/0.0.1
npm http 304 https://registry.npmjs.org/xmlhttprequest/1.4.2
npm http GET https://registry.npmjs.org/zeparser/0.0.5
npm http GET https://registry.npmjs.org/commander
npm http GET https://registry.npmjs.org/tinycolor
npm http GET https://registry.npmjs.org/options
npm http 304 https://registry.npmjs.org/zeparser/0.0.5
npm http 304 https://registry.npmjs.org/tinycolor
npm http 304 https://registry.npmjs.org/commander
npm http 304 https://registry.npmjs.org/options
> [email protected] install /usr/local/lib/node_modules/socket.io-client/node_modules/ws
> node install.js
[ws v0.4.21] Attempting to compile blazing fast native extensions.
[ws v0.4.21] Native extension compilation successful!
[email protected] /usr/local/lib/node_modules/socket.io-client
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected], [email protected])
ok so i can see it installed it in my /usr/local/lib/node_modules/socket.io-client/
so i went and grabbed the folder and copied it into the node_modules folder in titanium. and ran chat.js
node chat.js
Amazing i now have socket.io started
info - socket.io started
Ok so now it wont build so i had to copy this into my .project file
<buildSpec>
<buildCommand>
<name>com.aptana.ide.core.unifiedBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.appcelerator.titanium.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.appcelerator.titanium.mobile.nature</nature>
<nature>com.aptana.projects.webnature</nature>
<nature>com.aptana.ruby.core.rubynature</nature>
</natures>
Open TiApp.xml and reselect the titanium SDK and select ipad iphone and android as my deploy targets and save.
Great i can now run the project
I get a popup Errors exist in required project(s) socket.io-titanium proceed with launch i click ok. it builds but i am just greeted with a empty project see image below.
http://isdrandom.s3.amazonaws.com/Screen%20Shot%202012-08-24%20at%2010.08.10.png
in the debug i get
[DEBUG] upload start w/ download:false
Right i have got this far can you please help with getting this to work
Thanks
Hi Rene
I know have this fired up and it is working on the mobile devices, but i am getting this through the browser.
XMLHttpRequest cannot load http://127.0.0.1:8080/socket.io/1/?t=1345803254195. Cannot use wildcard in Access-Control-Allow-Origin when credentials flag is true.
sorry to keep commenting
just thought it my be handy for anyone who is trying to get this working
The output of the chat.js node server is
handshake authorized 1459053066821082569
Any help on this thanks
I had some strange problems to. I decided to rename (alternetively delete) the node_modules directory in the chat example directory.
It turns out that thèrese might be a versioning problem somewhere.
Nevermind - when i removed the node_modules node will use any global modules instead. Now my setup works just fine.
Btw I'm new to node development so you should consider any advice i can give you carefully beboer implementing.
Did you now about the nodecasts.net? Checkout these no frill node screencasts http://nodecasts.net/