public interface Net
Net.HttpRequest
with the HTTP method (see Net.HttpMethods
for common methods) and
invoke sendHttpRequest(HttpRequest, HttpResponseListener)
with it and a Net.HttpResponseListener
. After the HTTP
request was processed, the Net.HttpResponseListener
is called with a Net.HttpResponse
with the HTTP response values and
an status code to determine if the request was successful or not.
To create a TCP client socket to communicate with a remote TCP server, invoke the
newClientSocket(Protocol, String, int, SocketHints)
method. The returned Socket
offers an InputStream
and OutputStream
to communicate with the end point.
To create a TCP server socket that waits for incoming connections, invoke the
newServerSocket(Protocol, int, ServerSocketHints)
method. The returned ServerSocket
offers an
ServerSocket.accept(SocketHints options)
method that waits for an incoming connection.Modifier and Type | Interface and Description |
---|---|
static interface |
Net.HttpMethods
Provides common HTTP methods to use when creating a
Net.HttpRequest . |
static class |
Net.HttpRequest
Contains getters and setters for the following parameters:
httpMethod: GET or POST are most common, can use
HttpMethods for static
references
url: the url
headers: a map of the headers, setter can be called multiple times
timeout: time spent trying to connect before giving up
content: A string containing the data to be used when processing the HTTP request.
Abstracts the concept of a HTTP Request: |
static interface |
Net.HttpResponse
HTTP response interface with methods to get the response data as a byte[], a
String or an InputStream . |
static interface |
Net.HttpResponseListener
Listener to be able to do custom logic once the
Net.HttpResponse is ready to be processed, register it with
sendHttpRequest(HttpRequest, HttpResponseListener) . |
static class |
Net.Protocol
|
Modifier and Type | Method and Description |
---|---|
void |
cancelHttpRequest(Net.HttpRequest httpRequest) |
Socket |
newClientSocket(Net.Protocol protocol,
String host,
int port,
SocketHints hints)
Creates a new TCP client socket that connects to the given host and port.
|
ServerSocket |
newServerSocket(Net.Protocol protocol,
int port,
ServerSocketHints hints)
Creates a new server socket on the given port, using the given
Net.Protocol , waiting for incoming connections. |
void |
openURI(String URI)
Launches the default browser to display a URI.
|
void |
sendHttpRequest(Net.HttpRequest httpRequest,
Net.HttpResponseListener httpResponseListener)
Process the specified
Net.HttpRequest and reports the Net.HttpResponse to the specified Net.HttpResponseListener
. |
void sendHttpRequest(Net.HttpRequest httpRequest, Net.HttpResponseListener httpResponseListener)
Net.HttpRequest
and reports the Net.HttpResponse
to the specified Net.HttpResponseListener
.httpRequest
- The Net.HttpRequest
to be performed.httpResponseListener
- The Net.HttpResponseListener
to call once the HTTP response is ready to be processed. Could
be null, in that case no listener is called.void cancelHttpRequest(Net.HttpRequest httpRequest)
ServerSocket newServerSocket(Net.Protocol protocol, int port, ServerSocketHints hints)
Net.Protocol
, waiting for incoming connections.port
- the port to listen onhints
- additional ServerSocketHints
used to create the socket. Input null to use the default setting provided
by the system.ServerSocket
GdxRuntimeException
- in case the socket couldn't be openedSocket newClientSocket(Net.Protocol protocol, String host, int port, SocketHints hints)
host
- the host addressport
- the porthints
- additional SocketHints
used to create the socket. Input null to use the default setting provided by the
system.void openURI(String URI)
URI
- the URI to be opened.Copyright © 2014. All rights reserved.