GithubHelp home page GithubHelp logo

omorandi / tiws Goto Github PK

View Code? Open in Web Editor NEW
131.0 29.0 64.0 17.5 MB

a very simple Titanium module (iOS / Android) for creating native websockets

JavaScript 70.08% Python 2.39% Makefile 0.22% Java 7.27% Objective-C 17.07% C 2.96%

tiws's Introduction

TiWS Module

#ANNOUNCEMENT The ownership of this module's repository has been transferred from Jordi Domenech (@iamyellow) to me (@omorandi), in order to ensure its active maintenance and to move the project forward.

Description

tiws is a very simple Titanium module (iOS / Android) for creating native websockets. it is also possible use tiws with Socket.IO and Now.js

Quick Start

Get it gitTio

Download the latest distribution ZIP-file and consult the Titanium Documentation on how install it, or simply use the gitTio CLI:

$ gittio install net.iamyellow.tiws

Contributors

10  Olivier Morandi
 9  jordi domenech
 8  tom quas
 4  Hilko Lantinga
 4  AppWerft
 4  ndob
 2  Jin-Sih Lin

License

tiws

Copyright 2012-2014 jordi domenech [email protected] Apache License, Version 2.0

Socket.IO

Copyright(c) 2011 LearnBoost [email protected] MIT Licensed

Now.js

Copyright (C) 2011 by Flotype Inc. [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

tiws's People

Contributors

appwerft avatar brianjd avatar gimdongwoo avatar iamyellow avatar ndob avatar nextlight avatar omorandi avatar pct avatar tomquas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tiws's Issues

Description of changes in socket.io and now.js

First of all, great stuff! It works flawlessly and finally allows me to drop the webview! (I fired events between nowjs in the webview and the "native" js.)

Could you make a description of what you changed in socket.io and now.js so it would be possible to update them or maintain the project if you ever decide to abandon it?

Titanium SDK 7.0.x

The latest distribution version 2.0 for Android doesn't appear to work with Titanium SDK 7.0.x.

When will there be an updated version?

Thanks

Added 1000+ Semi Colons to tiws Examples

@omorandi I added your module to my Titanium IDE today and received warnings about missing semi colons.

I didn't try to run my app before I removed the warnings so I'm not sure if it would have worked without removing the warnings. I didn't realise when I started just how many warnings there were. Turned out to be over 1000. I can probably let you have the updated files if you need them.

My main reason for posting is more of a question than an issue.

Could you please explain the difference between using tiws with "plain" websockets and socket.io / now.js?

Does this module work with Android?

Does anyone have this module working with Android and the latest version of Titanium?

I have spent hours trying to get it to work but no joy.

If you are running this module with Titanium could you please advise how you added the module and any other tweaks you made, thanks.

wss:// not works - Android

tiws seems not connect when using wss://
It fires the ''close'' event and the 'ev' object is this:
{"type":"close","source":{"apiName":"Ti.Proxy","bubbleParent":true,"_events":{"open":{},"close":{},"error":{},"message":{}}},"reason":"SSL","code":0,"bubbles":false,"cancelBubble":false}

OS: Android
Titanium SDK: 8.2.1.GA

On ios production compile app crashes

socket.io is crashing on ios in a production enviroment. When compiling in developmetn it works perfectly, on the otherhand, using both distribution to app store or using ad hoc app, it is returning

Application received error: Parse error at socket.io.js (line 60)
: [ERROR] Application received error: Module "./lib/socket.io" failed to leave a valid exports object at app.js (line 0)

now so far we havent manged to identify the location of this parse error.

wss:// ssl support

Hi @omorandi,

We have an issue when we use "wss://" with raw createWS() in iOS.
Websocket doesn't connect to server.
If we use "ws://", then everything looks fine.
Are there any known issue with it?

Thanks!

HTTP Error (java.io.IOException): 400 : Bad Request when connecting to socket.io

Using the latest 2.0.0 module for Android.
Titanium SDK 6.1.0 GA.
Latest socket.io implementation on server
JDK version jdk1.8.0_131

Below is the code

var uri='http://ip:3000';

var io = require('socket.io'),
socket = io.connect(uri);

socket.on('connect', function () {
Ti.API.log('connected!');
});

Below is the error

TiHTTPClient: (TiHttpClient-133) [45,45] HTTP Error (java.io.IOException): 400 : Bad Request
[ERROR] : TiHTTPClient: java.io.IOException: 400 : Bad Request
[ERROR] : TiHTTPClient: at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1266)
[ERROR] : TiHTTPClient: at java.lang.Thread.run(Thread.java:818)

Any solution for it would be really appreciated.

iOS module to 64-bit

As you may know, all iOS Apps that will be released after February 1st, 2015 should be 64-bit. Would it be possible to update this Module to 64-bit ?

iOS - crashing of app after connect

Hi,

on android the module works fine, but on iOS the app crashes. I have tried with socketio.js from example and the newer from this "forum".
this is log from adroid client:

debug: client authorized
info: handshake authorized crqMwdAhZnSJ_AVsPKBd
debug: setting request GET /socket.io/1/websocket/crqMwdAhZnSJ_AVsPKBd
debug: client authorized for 
debug: websocket writing 1::

and this from iOS:

debug: client authorized
info: handshake authorized lTC9by6zi_2KS25SPKBc
debug: websocket writing 2::

you can see, the line 'bug: setting request GET /socket.io/1/websocket/crqMwdAhZnSJ_AVsPKBd' is missing.

I have used the binary from git and I recompiled againtst 3.2.3.GA. All the same issue.

No https connection with socket.io

I'm using http connection and all works fine. Now on server have activated https on socket but in the app it don't works. I don't receive any error of connection and I don't understand the problem.

`
io.connect(myHttpsUrl, {

'reconnection' : true,
'reconnectionDelay' : 500,
transports : ["websocket"]
});
`

I tried with param secure : true too. Can you help me?

Not possible to get current state

It would be very handy to get the current connection state.

IE: I'd like to check if we're in a connected state before calling ws.close() -- this way I won't have hook.error() pop if I close a closed connection.

Can not connect to node server

Hello,
I have been trying to use socket.io to connect to a node server running on a secure port using wss or ws. I have not had much luck in the past couple of days. I need to send a message to the node server using socket.io. Here is my code (I am using net.iamyellow.tiws):

VOOMZI_WS = 'wss://my_ip_address:9443';
var io = require('socket.io');
var socket = io.connect(Alloy.Globals.VOOMZI_WS, {
'transports' : ['websocket']
});
socket.on('connect', function() {
console.log('connected');
});
socket.on('error', function(e) {
console.log('disconnected: ' + JSON.stringify(e));
});
The end result is always the same "disconnected: 'The network connection was lost.'" I am using a self-signed certificate, BTW.

Can someone tell me why is this happening?

Greatly appreciate any help here.

add support for custom request headers

i need to open a websocket with an 'If-Modified-Since' request header so the backend knows it doesn't have to nuke my client with outdated data. any plans to implement this?

Still active?

Hello!

I just wanted to check in and see if this repository is still actively being maintained.

Thanks!

Support for sdk 8.x

Is it possible to get an update for Ti SDL 8.x ?
I have an clean project where I wanted to add this module, but the app keeps crashing during build. If I remove the ref to the module from tiapp.xml then everything is wokring. "Well besidde the module :) "

Error that shows up in console is :

[ERROR] �� �** BUILD FAILED ** [ERROR] �� �The following build commands failed: [ERROR] �� � Ld /Users/lukic/Desktop/Lukic/Apps/Test/build/iphone/build/Products/Debug-iphonesimulator/Test.app/Test normal x86_64 [ERROR] �� �(1 failure) Build failed. Process exited with code 1.

Minimal Ti SDK

I'd make it 3.4.1 to be sure it will work with android 5. Just a thought :)

Headers

If I need to pass in headers at the same time as the ws information is there a way to do that? I can do it in this lib for nodejs https://github.com/websockets/ws this way:

var url = 'ws://' + auth + '@' + host + '/rest/subscribe';

var ws = new WebSocket(url, 'ISYSUB', {
    origin: 'blah',
    protocolVersion: 13
});

ws.on('message', function message(data, flags) {
    console.log(data);
  ;

but I need to do it for a titanium app.

websockets idea

Many users use socket.io or engine.io or just websockets (and there are more).
To tackle this problem and make our programs future proof I use this:
https://github.com/primus/primus

That is a global node.js server (and client) and you can add your own socket.

Then I thought how can I connect to my primus node.js server using android and ios using one framework (titanium) using websockets. I can't..

But what I can do is using Xcode to connect to primus using this:
https://github.com/daltoniam/Starscream/blob/master/WebSocket.swift with the websockets transport
and this uri: wss://hostname:8091/primus/?ns=e98f6d3a69e800563fff46a30997889075f2ddf8

In other words, could you check if its possible to connect to a simple primus server ?
using transport: websocket, socket.io, or engine.io
Just a simple connection , sending, receiving is enough.

After that, the users can create a primus server, choose a transport and use ios or android ! :)

Crash on app resume

I'm getting an app crash when the app is resumed. Wasn't getting this before I added the module. I'm using the socket.io implementation of the module (v0.9.10). The error on SRWebSocket.m:591 makes me believe that its this module causing the issue. I have no resume/resumed event utilizing the socket. I'm running the .3 version from the Appc Market.

Any ideas?

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x40000010
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libobjc.A.dylib                 0x3b450536 objc_retain + 6
1   Here On Biz                     0x00266d5a __block_global_1 (SRWebSocket.m:591)
2   libdispatch.dylib               0x3b86d790 _dispatch_call_block_and_release + 8
3   libdispatch.dylib               0x3b86d5d8 _dispatch_client_callout + 20
4   libdispatch.dylib               0x3b870e40 _dispatch_main_queue_callback_4CF + 224
5   CoreFoundation                  0x337361ac __CFRunLoopRun + 1284
6   CoreFoundation                  0x336a9238 CFRunLoopRunSpecific + 352
7   CoreFoundation                  0x336a90c4 CFRunLoopRunInMode + 100
8   GraphicsServices                0x37287336 GSEventRunModal + 70
9   UIKit                           0x355c52b4 UIApplicationMain + 1116
10  Here On Biz                     0x000b2ea2 main (main.m:36)
11  Here On Biz                     0x000b249c start + 36

Make the API W3C compliant

In order to simplify the integration with third party JS libs, it would make sense wrapping the module with a pure JS API, compliant with W3C specs.

Android code depends on deprecated org.apache.http.*

The org.apache.http.* library is removed from Android 23, and now we need to link with org.apache.http.legacy.jar (copy from android-sdk/platforms/android-23/optional to android/lib).

Need to replace the code with something else.

Getting more done in GitHub with ZenHub

Hola! @sf-jin-ku has created a ZenHub account for the omorandi organization. ZenHub is the only project management tool integrated natively in GitHub – created specifically for fast-moving, software-driven teams.


How do I use ZenHub?

To get set up with ZenHub, all you have to do is download the browser extension and log in with your GitHub account. Once you do, you’ll get access to ZenHub’s complete feature-set immediately.

What can ZenHub do?

ZenHub adds a series of enhancements directly inside the GitHub UI:

  • Real-time, customizable task boards for GitHub issues;
  • Multi-Repository burndown charts, estimates, and velocity tracking based on GitHub Milestones;
  • Personal to-do lists and task prioritization;
  • Time-saving shortcuts – like a quick repo switcher, a “Move issue” button, and much more.

Add ZenHub to GitHub

Still curious? See more ZenHub features or read user reviews. This issue was written by your friendly ZenHub bot, posted by request from @sf-jin-ku.

ZenHub Board

iOS message event not fired?

Hi, I create a basic app with the example in app.js.

All client works exept for iOS that connects but not receive messages

Anyone?

Error trying to connect http server with socket.io

I'm trying to use that library but it get error when I try to connect with socket.io

[INFO] : error!"{"code":0,"message":"Transport unknown"}"
[INFO] : error!"HTTP error"

var io = require('socket.io'),
socket = io.connect(uri);

socket.on('connect', function (e) {
    Ti.API.log('connected!');
});


socket.on('error', function (e) {
    Ti.API.log('error!' + JSON.stringify(e));
});

How can help me?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.