javax.websocket
Class Endpoint

java.lang.Object
  extended by javax.websocket.Endpoint

public abstract class Endpoint
extends Object

The Web Socket Endpoint represents an object that can handle a web socket conversations. When deployed as a server endpoint, that is to say, the endpoint is registered to a URL, the server instantiates a new endpoint instance for each client connection. If deployed as a client, the endpoint will be instantiated once per single connection to the server. If the endpoint is a server which will cater to multiple clients, each endpoint instance corresponding to each active client is called by no more than one thread at a time. This means that when implementing/overriding the methods of Endpoint, the developer is guaranteed that there will be at most one thread in each endpoint instance.

Since:
DRAFT 001
Author:
dannycoward

Constructor Summary
Endpoint()
           
 
Method Summary
abstract  EndpointConfiguration getEndpointConfiguration()
          Developers must provide an EndpointConfiguration so that the container it is deployed in can configure it.
 void onClose(CloseReason closeReason)
          This method is called when the session with the client is terminated.
 void onError(Throwable thr)
          Developers may implement this method when the web socket session creates some kind of error that is not modeled in the web socket protocol.
abstract  void onOpen(Session session)
          Developers must implement this method to be notified when a new conversation has just begun.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Endpoint

public Endpoint()
Method Detail

getEndpointConfiguration

public abstract EndpointConfiguration getEndpointConfiguration()
Developers must provide an EndpointConfiguration so that the container it is deployed in can configure it.

Returns:
an EndpointConfiguration used to configure the Endpoint

onOpen

public abstract void onOpen(Session session)
Developers must implement this method to be notified when a new conversation has just begun.

Parameters:
session - the session that has just been activated.

onClose

public void onClose(CloseReason closeReason)
This method is called when the session with the client is terminated.

Parameters:
closeReason - the reason the session was closed.

onError

public void onError(Throwable thr)
Developers may implement this method when the web socket session creates some kind of error that is not modeled in the web socket protocol. This may for example be a notification that an incoming message is too big to handle, or that the incoming message could not be encoded.

There are a number of categories of exception that this method is (currently) defined to handle:-
- connection problems, for example, a socket failure that occurs before the web socket connection can be formally closed.
- errors thrown by developer create message handlers calls.
- conversion errors encoding incoming messages before any message handler has been called.
TBD We may come up with less of a 'catch-all' mechanism for handling exceptions, especially given the varying nature of these categories of exception.

Parameters:
thr - the throwable representing the problem.



Copyright © 2012 Oracle and/or its affiliates. All rights reserved.