Package com.ngrok
Interface Session
-
- All Superinterfaces:
AutoCloseable
public interface Session extends AutoCloseable
A session with the ngrok service.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classSession.BuilderA builder for creating a sessionstatic classSession.ClientInfoRepresents additional information about the client.static interfaceSession.CommandHandlerProvides a way to listen for specific server side events.static interfaceSession.HeartbeatHandlerProvides a way to monitor current session's heartbeats and disconnects.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidclose()voidcloseForwarder(String forwarderId)Closes a forwarder by its IDvoidcloseListener(String listenerId)Closes a listener by its IDstatic Sessionconnect(Session.Builder builder)Connects a session with specifiedSession.Builderdefault EdgeBuilderedge()Creates a newEdgeBuilderassociated with this session.Forwarder.EdgeforwardEdge(EdgeBuilder builder, URL url)Configures and starts aForwarder.EdgeForwarder.EndpointforwardHttp(HttpBuilder builder, URL url)Configures and starts a HTTPForwarder.EndpointForwarder.EndpointforwardTcp(TcpBuilder builder, URL url)Configures and starts a TCPForwarder.EndpointForwarder.EndpointforwardTls(TlsBuilder builder, URL url)Configures and starts a TLSForwarder.EndpointStringgetId()Returns the ID of this sessionStringgetMetadata()Returns the metadata of this sessiondefault HttpBuilderhttpEndpoint()Creates a newHttpBuilderassociated with this session.Listener.EdgelistenEdge(EdgeBuilder builder)Configures and starts aListener.EdgeListener.EndpointlistenHttp(HttpBuilder builder)Configures and starts a HTTPListener.EndpointListener.EndpointlistenTcp(TcpBuilder builder)Configures and starts a TCPListener.EndpointListener.EndpointlistenTls(TlsBuilder builder)Configures and starts a TLSListener.Endpointdefault TcpBuildertcpEndpoint()Creates a newTcpBuilderassociated with this session.default TlsBuildertlsEndpoint()Creates a newTlsBuilderassociated with this session.static Session.BuilderwithAuthtoken(String authtoken)Creates a new sessionSession.Builderwith specified ngrok authtokenstatic Session.BuilderwithAuthtokenFromEnv()Creates a new sessionSession.Builderresolving the ngrok authtoken fromNGROK_AUTHTOKENenv variable
-
-
-
Method Detail
-
withAuthtoken
static Session.Builder withAuthtoken(String authtoken)
Creates a new sessionSession.Builderwith specified ngrok authtoken- Parameters:
authtoken- the authtoken- Returns:
- the builder
-
withAuthtokenFromEnv
static Session.Builder withAuthtokenFromEnv()
Creates a new sessionSession.Builderresolving the ngrok authtoken fromNGROK_AUTHTOKENenv variable- Returns:
- the builder
-
connect
static Session connect(Session.Builder builder) throws IOException
Connects a session with specifiedSession.Builder- Parameters:
builder- the builder- Returns:
- newly created session
- Throws:
IOException- if an I/O error occurs
-
getId
String getId()
Returns the ID of this session- Returns:
- session ID
-
getMetadata
String getMetadata()
Returns the metadata of this session- Returns:
- session metadata
-
tcpEndpoint
default TcpBuilder tcpEndpoint()
Creates a newTcpBuilderassociated with this session.- Returns:
- the builder
-
listenTcp
Listener.Endpoint listenTcp(TcpBuilder builder) throws IOException
Configures and starts a TCPListener.Endpoint- Parameters:
builder- the builder- Returns:
- the running listener
- Throws:
IOException- if an I/O error occurs
-
forwardTcp
Forwarder.Endpoint forwardTcp(TcpBuilder builder, URL url) throws IOException
Configures and starts a TCPForwarder.Endpoint- Parameters:
builder- the builderurl- the url to forward to- Returns:
- the running forwarder
- Throws:
IOException- if an I/O error occurs
-
tlsEndpoint
default TlsBuilder tlsEndpoint()
Creates a newTlsBuilderassociated with this session.- Returns:
- the builder
-
listenTls
Listener.Endpoint listenTls(TlsBuilder builder) throws IOException
Configures and starts a TLSListener.Endpoint- Parameters:
builder- the builder- Returns:
- the running listener
- Throws:
IOException- if an I/O error occurs
-
forwardTls
Forwarder.Endpoint forwardTls(TlsBuilder builder, URL url) throws IOException
Configures and starts a TLSForwarder.Endpoint- Parameters:
builder- the builderurl- the url to forward to- Returns:
- the running forwarder
- Throws:
IOException- if an I/O error occurs
-
httpEndpoint
default HttpBuilder httpEndpoint()
Creates a newHttpBuilderassociated with this session.- Returns:
- the builder
-
listenHttp
Listener.Endpoint listenHttp(HttpBuilder builder) throws IOException
Configures and starts a HTTPListener.Endpoint- Parameters:
builder- the builder- Returns:
- the running listener
- Throws:
IOException- if an I/O error occurs
-
forwardHttp
Forwarder.Endpoint forwardHttp(HttpBuilder builder, URL url) throws IOException
Configures and starts a HTTPForwarder.Endpoint- Parameters:
builder- the builderurl- the url to forward to- Returns:
- the running forwarder
- Throws:
IOException- if an I/O error occurs
-
edge
default EdgeBuilder edge()
Creates a newEdgeBuilderassociated with this session.- Returns:
- the builder
-
listenEdge
Listener.Edge listenEdge(EdgeBuilder builder) throws IOException
Configures and starts aListener.Edge- Parameters:
builder- the builder- Returns:
- the running listener
- Throws:
IOException- if an I/O error occurs
-
forwardEdge
Forwarder.Edge forwardEdge(EdgeBuilder builder, URL url) throws IOException
Configures and starts aForwarder.Edge- Parameters:
builder- the builderurl- the url to forward to- Returns:
- the running forwarder
- Throws:
IOException- if an I/O error occurs
-
closeListener
void closeListener(String listenerId) throws IOException
Closes a listener by its ID- Parameters:
listenerId- the listener ID- Throws:
IOException- if an I/O error occurs
-
closeForwarder
void closeForwarder(String forwarderId) throws IOException
Closes a forwarder by its ID- Parameters:
forwarderId- the forwarder ID- Throws:
IOException- if an I/O error occurs
-
close
void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-
-