WebSockets Send Message to Client

35 views
Skip to first unread message

ZeeCaptain

unread,
Jan 29, 2016, 7:52:02 AM1/29/16
to CodenameOne Discussions

i want to write a simple App for me (Android).
For this it is necessary that the server can send data to my client without a response of it to the server (only one client at a time over internal network) but unfortunately i have no idea how to use sockets or websockets with codename one.
Can someone please post a small examplecode how to establish connection, listen on it and send some small data (to the client)?
I want to write the server on my own instead of using Tomcat becaues i am not even sure what this is.

Due to the fact that i dont have the money to use pro, i can't use push and i don't want to use pubnub because it seems that the data is relayed over other servers in the internet.
I took a look at the example how to write a simple chat but i don't understand how it works (seems some tomcat magic).

I hope your can help me.

greetings from germany

Captain

IDE: Eclipse
Desktop OS: Windows 8.1
Target Server: Centos
Simulator: Codename One Simulator
Device: Asus Memo Pad

Housseini Moussa

unread,
Jan 29, 2016, 10:27:24 AM1/29/16
to CodenameOne Discussions, spam-...@web.de
Please use this link to get more informaton on how to use websocket with codenameone: https://github.com/shannah/cn1-websockets

spam-...@web.de

unread,
Jan 29, 2016, 12:49:19 PM1/29/16
to CodenameOne Discussions, spam-...@web.de
Thank you, but i took a look at this first after downloading the lib.
Unfortunately this can't help me because there is no listening on the sockets and i think Tomcat handles this.
I want to write the server on my own (incl. listening on the incoming connections).

So do you have another example code?

greetings

Captain

Shai Almog

unread,
Jan 30, 2016, 1:19:19 AM1/30/16
to CodenameOne Discussions, spam-...@web.de
You can write the server on your own in tomcat using websockets http://stackoverflow.com/questions/35063803/codename-one-sockets-send-message-to-client

It sounds that what you are looking for isn't sockets or web but rather push support.

spam-...@web.de

unread,
Jan 30, 2016, 5:05:50 AM1/30/16
to CodenameOne Discussions, spam-...@web.de
Oh i got it. I does not need websockets.. Sorry, i am totally new in developing with codename one and using sockets/websockets so i thought that would be the same. but with the possibility to use it async.
I will take a look at the cn1sockets or the normal sockets (already took a look but wasn't able to get a writer or reader). Thanks for your help!
Reply all
Reply to author
Forward
0 new messages