jWebSocket Forum

[Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
My first jWebSocket Listener problem  XML
Forum Index » Server side Plug-Ins, Apps, Listeners and Filters
Author Message
dromani

jWebSocket Forum Fan
[Avatar]

Joined: 14/02/2011 19:00:26
Messages: 72
Location: Spain
Offline

Hello everybody.

I can't register my first jWebSocket Listener. I'm trying code from howto jWebSocket Listener tutorial. I started a jWebServer standalone, then my test class at server-side can't connect to server.

Can you help me please? Thanks.

[WWW] [MSN]
aschulze

jWebSocket Owner
[Avatar]

Joined: 16/03/2010 18:15:55
Messages: 375
Location: Germany, Herzogenrath
Offline

Hi dromani,

the problem is that you have no main loop: the program (and thus the server in the same process) immediately terminates!
Please use something like this (take a note of the main loop until the server gets the shutdown request):

Regards
Alex

This message was edited 2 times. Last update was at 17/02/2011 16:02:20

[WWW]
dromani

jWebSocket Forum Fan
[Avatar]

Joined: 14/02/2011 19:00:26
Messages: 72
Location: Spain
Offline

Thanks.

But I don't understand jWebSocketFactory.start() method very well... I need a JWebSocketServer (stand-alone) running? Or this method creates a new JWebSocketServer?

In both cases I got same error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/jwebsocket/api/PluginConfiguration

This message was edited 1 time. Last update was at 17/02/2011 20:00:17

[WWW] [MSN]
dromani

jWebSocket Forum Fan
[Avatar]

Joined: 14/02/2011 19:00:26
Messages: 72
Location: Spain
Offline

Ok. I fix all of my problems. I have a JWebSocket running and listening with my custom listener.

However I think that it would be better in "1st JWebSocketListener" include some tips:

1- Need to add jars into java project library
2- Need to define JWEBSOCKET_HOME into java project
3- Need to attach xml file with server config
4- Include JWebSocketFactory start & stop methods
5- Remember stay server running


Thank you very much aschulze!

This message was edited 1 time. Last update was at 19/02/2011 17:22:31

[WWW] [MSN]
wireless

jWebSocket Forum User

Joined: 29/09/2011 14:36:09
Messages: 2
Offline

i've similiar problems.

how do you register your Listener?

I've an eclipse project, where all .jar's from the lib-directory are included. Running the project is possible and the jwebsocket servers starts. Now, i want to register my Listener.

Do i have to create another another class registers the listener or is it possible to do this within the Listener-class...?
dromani

jWebSocket Forum Fan
[Avatar]

Joined: 14/02/2011 19:00:26
Messages: 72
Location: Spain
Offline

Hello wireless:

Define a class than implements WebSocketServerTokenListener like this:

Then on your static void main method put this:

Remember that you need to make some kind of loop to keep alive your tokenServer.
[WWW] [MSN]
ncolomer

jWebSocket Forum User

Joined: 13/09/2011 13:52:14
Messages: 7
Location: Paris
Offline

wireless wrote:how do you register your Listener?


I think Alexander gave the solution in his post :


Here, the added listener is JWebSocketTokenListenerSample. But you can write your own by implementing the server listener interface (WebSocketServerListener).

Unfortunately, it seems this interface is not documented in the online Javadoc. But you should access the docs via the sources.

Please also refer to the listener tutorial page to learn more on this subject.

-- Nicolas
[WWW]
marty

jWebSocket Forum User

Joined: 23/10/2011 23:41:50
Messages: 5
Offline

Hi, new to jwebsocket, and am a bit confused.

I am also trying to get a first listener working. I have a Java app that uses embedded jetty to serve out data via http.

I want to allow this same app to server out data via websockets (and achieve some of the bidirectionel goodness that websockets can provide).

Is a "listener" embedded in my app, ie does it enable my app to serve out websockets like embedded Jetty starts an http(s) server?

Create a server side listener class
Register your listener at the jWebSocket Server
Create the client side code to process answers of the listener.
Use the listener's functions in your web pages


I am trying to follow this and probably confused by the embedded Jetty concept. Do I need to create my listener to access my existing code for data and process the request in the listener, drop the jar into the jWebSocket-<version>/libs folder, and modify jWebSockets.xml... there are no references to listeners, only plugins...

The "Create 1st Listener" tutorial leaves me unsure of how and where to place my code?

Cheers,
Marty

 
Forum Index » Server side Plug-Ins, Apps, Listeners and Filters
Go to:   
Powered by JForum 2.1.9 © JForum Team