public final class ServerConnection extends Object
The typical usage is:
final ServerConnection sn = new ServerConnection(); final Map<String, String> properties = ... // See HeaderProperties. new Thread() { public void run() { try { sn.runConnectionLoop(map, new ServerConnection.Listener() { public ServerConnection.ResponseProvider request(V8Request request) { return ServerConnection.ResponseProvider.create( request.createSuccessResponse(...)); } }); } catch (IOException ex) { ... } } }.start(); ... V8Event event = new V8Event(...); sn.send(event);
Modifier and Type | Class and Description |
---|---|
static interface |
ServerConnection.Listener
Listener receiving debugger events.
|
static class |
ServerConnection.ResponseProvider
Debugger response provider.
|
Constructor and Description |
---|
ServerConnection()
Create a new server listening connection with automatically selected port
number.
|
ServerConnection(int serverPort)
Create a new server listening connection on the specific port.
|
Modifier and Type | Method and Description |
---|---|
void |
addIOListener(IOListener iol)
Add an I/O listener to monitor the debugger communication.
|
void |
closeCurrentConnection()
Close the currently established client-server connection, if any.
|
void |
closeServer()
Close the server connection.
|
int |
getPort()
Get the port number this connection is listening on.
|
boolean |
isConnected() |
void |
removeIOListener(IOListener iol)
Remove an I/O listener monitoring the communication.
|
void |
runConnectionLoop(Map<String,String> properties,
ServerConnection.Listener listener)
Execute the debugger events loop.
|
void |
send(V8Event event)
Send a debugger event.
|
public ServerConnection() throws IOException
ServerConnection.getPort()
.IOException
- when an IO problem occurs.public ServerConnection(int serverPort) throws IOException, IllegalArgumentException
serverPort
- The port the connection is listening on.IOException
- when an IO problem occurs.IllegalArgumentException
- if the port parameter is outside the
specified range of valid port values, which is between 0 and 65535, inclusive.public void runConnectionLoop(Map<String,String> properties, ServerConnection.Listener listener) throws IOException
properties
- The map of properties to provide to the client as a header.
See HeaderProperties
listener
- The listener to receive the debugger events.IOException
- thrown when an IO problem occurs.public int getPort()
public void send(V8Event event) throws IOException
event
- An event to send to the client.IOException
- thrown when an IO problem occurs.public boolean isConnected()
public void closeCurrentConnection() throws IOException
ServerConnection.runConnectionLoop(java.util.Map, org.netbeans.lib.v8debug.connection.ServerConnection.Listener)
can then be executed again to accept another client connection.IOException
- thrown when an IO problem occurs.public void closeServer() throws IOException
IOException
- thrown when an IO problem occurs.public void addIOListener(IOListener iol)
iol
- an IOListenerpublic void removeIOListener(IOListener iol)
iol
- an IOListener