A Chat Demo with App Inventor and Easy Web Socket

5,533 views
Skip to first unread message

Taifun

unread,
Dec 30, 2012, 12:55:35 PM12/30/12
to ai...@googlegroups.com

see example http://puravidaapps.com/chat.php
Taifun

PS: a web socket enhancement for App Inventor would be nice...

Jos Flores

unread,
Dec 31, 2012, 8:17:11 AM12/31/12
to ai...@googlegroups.com
Hey Taifun,

very cool! as usual! :)

cheers,
José

Roger Belk

unread,
Dec 31, 2012, 8:20:22 AM12/31/12
to ai...@googlegroups.com
WOW! thats great Taifun, Keep up the good work.

Gary

unread,
Dec 31, 2012, 9:46:42 AM12/31/12
to ai...@googlegroups.com


On Sunday, December 30, 2012 11:55:35 AM UTC-6, Taifun wrote:
...


PS: a web socket enhancement for App Inventor would be nice...

What would the enhancement do?

Gary 

Taifun

unread,
Dec 31, 2012, 11:14:37 AM12/31/12
to ai...@googlegroups.com
thank you, guys! ;-)
Taifun
 
PS: a web socket enhancement for App Inventor would be nice...
What would the enhancement do?
It could provide real-time communication between different clients of the same app, see here:

http://jwebsocket.org/mobile/android/android_part1.htm

Whether on-line games, or online collaboration, streaming, chat, remote control or monitoring applications - real-time communication has long ago moved into the mobile devices. HTML5 WebSockets are the ideal basis for bidirectional high-speed data exchange in real time.


http://en.wikipedia.org/wiki/Websocket
WebSocket is a web technology providing full-duplex communications channels over a single TCP connection. The WebSocket API is being standardized by the W3C, and the WebSocket protocol has been standardized by the IETF as RFC 6455. WebSocket is designed to be implemented in web browsers and web servers, but it can be used by any client or server application. The WebSocket Protocol is an independent TCP-based protocol. Its only relationship to HTTP is that its handshake is interpreted by HTTP servers as an Upgrade request. The WebSocket protocol makes possible more interaction between a browser and a web site, facilitating live content and the creation of real-time games. This is made possible by providing a standardized way for the server to send content to the browser without being solicited by the client, and allowing for messages to be passed back and forth while keeping the connection open. In this way a two-way (bi-directional) ongoing conversation can take place between a browser and the server. A similar effect has been achieved in non-standardized ways using stop-gap technologies such as Comet.

Gary

unread,
Jan 1, 2013, 8:50:49 AM1/1/13
to ai...@googlegroups.com
I am not keeping up with what is happening with HTML5. Thanks Taifun.

is a simple demo of WebSockets. It tests if your browser supports WebSockets. You can see the browser version in the upper right of the page.

What I got:

These worked
Windows 7: Chrome 23 Windows
Nexus 7: Chrome 18 Linux

This did not
Droid X: Unknown Chrome Linux


The Nexus 7 has a current version of Android, the Droid X has an old version.

I did not test if App Inventor using the web components worked on the Nexus 7. It would probably work using an Activity Starter.

Anyone interested in testing both the web components and Activity Starter on a device that runs the demo page.

Gary

Taifun

unread,
Jan 1, 2013, 9:31:36 AM1/1/13
to ai...@googlegroups.com
unfortunately web socket generally is up to now not available for Android browsers, see also here http://caniuse.com/#feat=websockets
but this technology is not restricted to the web browser:

WebSocket is designed to be implemented in web browsers and web servers, but it can be used by any client or server application.
Taifun


Dennis A.

unread,
Jan 1, 2013, 9:43:46 AM1/1/13
to ai...@googlegroups.com
Taifun,
please clarify: "but this technology is not restricted to the web browser:"

Regarding the AI WEB VIEWER..
..  YES it works on the AI web viewer or NO it does not work on the AI web viewer?

thank you..
Dennis

Taifun

unread,
Jan 1, 2013, 10:25:07 AM1/1/13
to ai...@googlegroups.com
this technology is also new for me...


please clarify: "but this technology is not restricted to the web browser:"
this was said here: http://en.wikipedia.org/wiki/Websocket


Regarding the AI WEB VIEWER..
..  YES it works on the AI web viewer or NO it does not work on the AI web viewer?
it tried to explain everything here http://puravidaapps.com/chat.php
web socket does not work in Android browsers and therefore also not in the AI web viewer
but the chat example uses easywebsocket.org which works...
I think they are using a fallback solution, but I'm not sure...

and: web sockets could be an interesting future enhancement for App Inventor to enable communication between clients

more info about that technology also at stackoverflow http://stackoverflow.com/questions/tagged/websocket+android?sort=faq&pagesize=30
or google https://www.google.com/#hl=en&tbo=d&spell=1&q=websocket+android

Taifun

Gary

unread,
Jan 1, 2013, 2:39:51 PM1/1/13
to ai...@googlegroups.com

On Tuesday, January 1, 2013 9:25:07 AM UTC-6, Taifun wrote:
this technology is also new for me...
It looks new, good find!


web socket does not work in Android browsers and therefore also not in the AI web viewer
It works in the Nexus 7 web browser.

That is why I asked if someone wanted to do research  

"Anyone interested in testing both the web components and Activity Starter on a device that runs the demo page."
If I had the spare time, I would do some testing of the web components and starting a web page with Activity Starter.
  I'm guessing you can get it to work with Activity Starter. 
    But I do not know...

Gary

Taifun

unread,
Jan 1, 2013, 4:00:00 PM1/1/13
to ai...@googlegroups.com
"Anyone interested in testing both the web components and Activity Starter on a device that runs the demo page."
If I had the spare time, I would do some testing of the web components and starting a web page with Activity Starter.
  I'm guessing you can get it to work with Activity Starter. 
    But I do not know...
in 99% this does NOT work, see here http://caniuse.com/#feat=websockets ...
and here is a test page http://puravidaapps.com/websocket-test.html, you can open it with your Android browser or with the Activity Starter
Taifun


websocket-test.html

Gary

unread,
Jan 1, 2013, 6:44:07 PM1/1/13
to ai...@googlegroups.com


On Tuesday, January 1, 2013 3:00:00 PM UTC-6, Taifun wrote:
"Anyone interested in testing both the web components and Activity Starter on a device that runs the demo page."
If I had the spare time, I would do some testing of the web components and starting a web page with Activity Starter.
  I'm guessing you can get it to work with Activity Starter. 
    But I do not know...
in 99% this does NOT work, see here http://caniuse.com/#feat=websockets ...

The lucky 1% can get a head start.
I wonder how many devices 1% is? There are a lot of Nexus 4/7/10 and other phones that have jelly bean out there.
 
and here is a test page http://puravidaapps.com/websocket-test.html, you can open it with your Android browser or with the Activity Starter

Woo Hoo! Now if someone that can run the demo page comes up with source for test apps, we can look more.

What I am hoping (sorta) is that the browser and Activity Starter work and the we components do not. Then we have a clue that the version of the jars used with the web components is not as current as the browser.
And we have the technology...

I sorta was seeing that when I was testing HTML5 a long time ago. I did not confirm back then. Now we have source :-)

Gary 
 
Taifun


Dennis A.

unread,
Jan 1, 2013, 8:12:55 PM1/1/13
to ai...@googlegroups.com
quick test with AI web viewer fails..

Dennis

Jos Flores

unread,
Jan 2, 2013, 8:13:18 AM1/2/13
to ai...@googlegroups.com
Taifun is right about some solutions using fallbacks. I have worked
with socket.io, the technology that EasyWebSocket is built on top (a
websockets implementation for nodejs == JavaScript on the server
side), and it falls back to other technologies (degrading gracefully)
if the client does not support websockets, making it as transparent as
possible for the user.

But guys, this is a server side technology, I don't see how to
integrate this into AI other than the way Taifun is using. All the
work here is done in the server; in Taifun's case, this is given by
Easy Web Socket and the HTML page on the phone; in my case, we run our
own socket servers and serve our clients code from there. Either way,
all the work is pure JavaScript (and some markup), and it should be
mostly supported by the web viewer, but all the work is done outside
of App Inventor.

cheers,
José

Gary

unread,
Jan 2, 2013, 11:53:42 AM1/2/13
to ai...@googlegroups.com
Thanks Dennis.
What phone/version of Android.

And how about an Activity Starter example?

Taifun

unread,
Jan 2, 2013, 3:44:43 PM1/2/13
to ai...@googlegroups.com
I don't see how to integrate this into AI other than the way Taifun is using.
it would be nice to have some blocks directly in App Inventor without having to use the webviewer as workaround,
e.g. something like webSocket.Send and a webSocket.GotText event to receive a message
Taifun

Gary

unread,
Jan 3, 2013, 7:53:19 AM1/3/13
to ai...@googlegroups.com
:-)
So, a WebSocket component that understands the url ws[s]://host[:port/][path/][arguments]
and has blocks for the two methods send and close and handles the three events, onopen, onmessage, onclose.

:-)

Jos Flores

unread,
Jan 3, 2013, 8:31:15 AM1/3/13
to ai...@googlegroups.com
But guys, who is running the server? Because the client implementation
is also provided by the server. For instance, to use Easy Web Socket,
you have to include this client library:
http://easywebsocket.org/easyWebSocket.min.js

A different websockets server will have a different client library,
and there's no standard for these clients.

And what's more important... websockets is a technology for the
browser, in our case, a web viewer. If we don't want the browser, we
don't really need websockets, any kind of socket will do. Websockets
is only bringing to the browser what we already have outside of the
browser... are we missing the point?

I haven't tried the Game client/server component, but it seems to do
something very similar.

cheers,
José

Gary

unread,
Jan 4, 2013, 7:40:16 AM1/4/13
to ai...@googlegroups.com

On Thursday, January 3, 2013 7:31:15 AM UTC-6, Jos Flores wrote:
But guys, who is running the server? Because the client implementation
is also provided by the server. For instance, to use Easy Web Socket,

WebSockets is a standard. You should be able to use a server that supports the standard written in whatever language you want with clients that support the standard written in whatever language you want.

It will require a server. 
That did not stop Google from writing the twdb component. Using twdb in App Inventor makes it easy to do that part of a web app.

 
you have to include this client library:
http://easywebsocket.org/easyWebSocket.min.js

A different websockets server will have a different client library,
and there's no standard for these clients.

?

I am not saying it is currently easy to get clients and servers to talk with each other, I am saying it will be as the libraries mature.
 

And what's more important... websockets is a technology for the
browser, in our case, a web viewer. If we don't want the browser, we

?
WebSocket is designed to be implemented in web browsers and web servers, but it can be used by any client or server application.
 
don't really need websockets, any kind of socket will do. Websockets


 

 
is only bringing to the browser what we already have outside of the
browser... are we missing the point?

We are talking about issues with using WebSockets.
I do not have spare time to work on it. That could change some day and if we talk about some of the issues now, that code would be done that much better (given that I am sorta not sure what better would be :-))

 

I haven't tried the Game client/server component, but it seems to do
something very similar.

Interesting point. I wonder if that component could be redone in WebSockets (some day).

Gary 

Jos Flores

unread,
Jan 4, 2013, 8:03:03 AM1/4/13
to ai...@googlegroups.com
Why would you want to redo something with a different technology if
the final functionality is the same?

Just because websockets are the cool thing now? I don't get it.

BTW Websockets is a specification. Implementations in different
languages and platforms may vary largely, even if they follow the same
specification.

cheers,
José

Gary

unread,
Jan 4, 2013, 8:16:07 AM1/4/13
to ai...@googlegroups.com
Some follow up 

Gingerbread is currently on almost 50% of the devices out there

It's on my Droid X )-:

ICS is on almost 30%. 

Jellybean 4.2 is currently on a bit over 1%. 
The various Nexus 4/7/10 and other lucky folks.

Once we have a test app that uses Activity Starter to run a WebSocket example, We can test Firefox https://play.google.com/store/apps/details?id=org.mozilla.firefox

both will install on my well loved but mature Droid X.


We care (partly) because WebSockets is part of HTML5 (kinda ;-)) and HTML5 is now 'stable and feature complete' 

 "This means that (as far as the W3C sees it) businesses and developers have a "stable target" for implementation and planning the next generation of web applications."

Soooo

Those of us that are working with HTML5 are getting experience with where things will be for the next generation of apps.

But I digress :-)

Gary

Gary

unread,
Jan 4, 2013, 8:36:55 AM1/4/13
to ai...@googlegroups.com

On Friday, January 4, 2013 7:03:03 AM UTC-6, Jos Flores wrote:
Why would you want to redo something with a different technology if
the final functionality is the same?

WebSockets are (becoming) a standard. If we use them, we are using a technology that will get better and will be available more places.

Using sockets with App Inventor apps is not something I want to do.
What other technology does the same thing?

 

Just because websockets are the cool thing now? I don't get it.

I am interested in what could be added to App Inventor to support WebSockets 
and testing what the browsers on the devices can do with App Inventor. If it looks like something useful, we can look into using the current libraries to do the browser components. I already had a start with ai4a V1.2/V1.3. I am currently stumbling over issues with the code that OAuth uses in App Inventor when put into an Android app.
I do not have a need for a WebSocket component (currently :-))
 

BTW Websockets is a specification. Implementations in different
languages and platforms may vary largely, even if they follow the same
specification.

You are going to have to say more to clarify that for me José.

"The Common Object Request Broker Architecture (CORBA) is a standard defined by the Object Management Group (OMG) that enables software components written in multiple computer languages and running on multiple computers to work together (i.e., it supports multiple platforms)."

There were various implementations. BUT you could (eventually) get things written in one implementation working with another implementation.

If we were to move forward (which is not on my list of things todo (at least today)), I would look into a Java library that worked on Android and see about getting something up. Then take some time to see if what we had was a good way to go and it if was, do the next version. 
 

cheers,
José  :-)

Good conversation

Gary 

Jos Flores

unread,
Jan 4, 2013, 8:49:01 AM1/4/13
to ai...@googlegroups.com
Exploration is great, no doubt of that. But those of you working with
HTML5, sure are working with browsers. Websockets are sooooo exciting
because they bring sockets to the browser, which means that now we can
have bidirectional comms between browser/server instead of having to
pull from servers with http requests. This is awesome for games, and
all the other stuff already discussed in this thread. If you take the
browser out of the equation then all you need is a socket:
http://docs.oracle.com/javase/tutorial/networking/sockets/index.html

cheers,
José

Taifun

unread,
Jan 4, 2013, 10:57:54 AM1/4/13
to ai...@googlegroups.com
I haven't tried the Game client/server component, but it seems to do something very similar.
why does nobody use the game component?
-> because it is too complicated and there is no tutorial available!
a simple solution would be nice to have...
or do you know anybody who is using the game component?
I looked at this 1 year ago, but I don't remember why I did not continue... probably I should look at it again...

If you take the browser out of the equation then all you need is a socket

It will require a server. That did not stop Google from writing the twdb component. Using twdb in App Inventor makes it easy to do that part of a web app.
yes, the solution could be similar to the TinyWebDB solution...
Taifun

Anthony Barnes

unread,
Jan 4, 2013, 11:31:06 AM1/4/13
to ai...@googlegroups.com
Gary,
Do you still have the stuff that Eni sent us on the Game Client? I am unable to locate it.

Gary

unread,
Jan 4, 2013, 1:53:19 PM1/4/13
to ai...@googlegroups.com

On Friday, January 4, 2013 9:57:54 AM UTC-6, Taifun wrote:
I haven't tried the Game client/server component, but it seems to do something very similar.
why does nobody use the game component?
-> because it is too complicated and there is no tutorial available!
a simple solution would be nice to have...
or do you know anybody who is using the game component?
I looked at this 1 year ago, but I don't remember why I did not continue... probably I should look at it again...

I think the game component did not work.
 

If you take the browser out of the equation then all you need is a socket

Looks like sockets were made a 'feature' :-)
 

It will require a server. That did not stop Google from writing the twdb component. Using twdb in App Inventor makes it easy to do that part of a web app.
yes, the solution could be similar to the TinyWebDB solution...
Taifun


I saw that  two of the many server options were Apache and Tomcat. There were a lot others.

Gary
 

Gary

unread,
Jan 4, 2013, 1:54:17 PM1/4/13
to ai...@googlegroups.com


On Friday, January 4, 2013 10:31:06 AM UTC-6, Anthony Barnes wrote:
Gary,
Do you still have the stuff that Eni sent us on the Game Client? I am unable to locate it.

She sent the voting component http://code.google.com/p/app-inventor-voting/
Another interesting component that did not go anywhere.

Gary 

clift...@gmail.com

unread,
Oct 18, 2013, 2:20:51 AM10/18/13
to ai...@googlegroups.com
Hi Taifun,

I am new here and chance upon your Chat-Demo apps using the web socket.

I have copied the Chat.apk from your tutorial and installed it on 2 Samsung Galaxy S3 phones.
I could not see the display that says "so-and-so entered the chat" nor the messages entered and sent,
in either phone.  Do I need to do any changes to the apps (ie via the Appinventor Block Editor) before
using this Chat-Demo as designed?

Thanks in advice for your good advice.

Cheers,
Clifton


On Monday, 31 December 2012 01:55:35 UTC+8, Taifun wrote:

Taifun

unread,
Oct 18, 2013, 9:38:21 AM10/18/13
to ai...@googlegroups.com
somehow the Easy Web Socket chat demo does not work anymore,,. also not in the browser window... I don't know why...
try the PubNub chat instead http://puravidaapps.com/pubnub.php
Taifun

Taifun

unread,
Oct 18, 2013, 9:43:32 AM10/18/13
to ai...@googlegroups.com
it also does not work anymore in the chat demo of EasyWebSocket itself ... http://easywebsocket.org/contrib/chat/ ...
Taifun

clift...@gmail.com

unread,
Oct 20, 2013, 3:23:06 AM10/20/13
to ai...@googlegroups.com


On Friday, 18 October 2013 21:43:32 UTC+8, Taifun wrote:
it also does not work anymore in the chat demo of EasyWebSocket itself ... http://easywebsocket.org/contrib/chat/ ...
Taifun 

Taifun,

Thanks for replying, I appreciate it.

I am looking at the PubNub link now, quite a cool site.  2 questions for your kind assistance :

1)  to use the features provided by PubNub, I have to use Appinventor 2, is this correct?

2)  have you tried developed an app using the PubNub's feature to 'push' a notification to another phone (installed with the same app
but was not active)?  With the received 'push' notice, the latter phone user would then launch the app to respond to the notice.  If yes,
may I seek your advice to put the PubNub's code accordingly into the Appinventor Blocks to make this works?

Cheers,
Clifton

Taifun

unread,
Oct 20, 2013, 9:09:00 AM10/20/13
to ai...@googlegroups.com
1)  to use the features provided by PubNub, I have to use Appinventor 2, is this correct?
no, you also can use it with AI1

2)  have you tried developed an app using the PubNub's feature to 'push' a notification to another phone (installed with the same app but was not active)?  
I have not tried this, please test that and let us know what you find out
Taifun 

Khalid Abdulla

unread,
Oct 16, 2019, 4:40:49 PM10/16/19
to App Inventor for All
Old thread so not sure if anyone is still following this, but I arrived at this thread looking for a way to get websocket client working in App Inventor 2. I found the following extension did just what I needed - hope it's of help to someone else:

Reply all
Reply to author
Forward
0 new messages