views:

97

answers:

1

I am playing around with websockets and Jetty 7.1.6.v20100715.

I have a few questions, mostly because of the lack of info/explanation about these methods.

1st) What is the byte for in sendMessage(byte frame,String data).

2nd) Is there any reason for outbound.sendMessage(string) not to work if invoked from the WebSocket.onConnect() method?

Also, is there any good explanation on the Jetty implementation, and how it should be used?

http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/websocket/WebSocket.html

Thanks

A: 

The "mostly absent" Jetty documentation... I think the best way to use WebSockets that early is to read up the specification and to note that you can send nothing but Unicode strings through a WebSocket connection at this time.

To answer your questions:

  1. That byte is the "frame type" you are about to send. Currently, there is only a frame type for Unicode strings defined, and therefore you can just use the sendMessage(String) method. In my oppinion the send* methods besides the one mentioned should not be public to avoid confusion, but thats true for lots of methods in the Jetty API and they don't seem to care. It seems to be prepared for sending binary data, but AFAIK there is no browser out there that supports anything but Unicode messages so in practice it's useless.

  2. To my knowledge it should be OK to do sob but the total lack of documentation on the Jetty side makes this a risky business. That's why I opted for sending the first message from the client to the server to get the protocol running, which works fine.

(Please note that my WebSockt knowledge is ~6 months old and this subject is evolving very fast)

Waldheinz
Thanks for the response. Regarding 2), yes, I had to do the same to have it working: wait for the client to send the first message to the server.
DanC