|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface PushServer
The server to which connections are made by clients. This interface represents the core functionality of the Comet and HTTP Push server.
To create and start an implementation of the server use one of the NIOServer constructors
NIOServer| Method Summary | |
|---|---|
void |
addContext(String context,
com.streamhub.handler.Handler handler)
Adds or overrides a context. |
void |
addStaticContent(File directory)
Adds a directory to be served from the root context / as if it were
a standard HTTP server. |
void |
addStaticContent(File directory,
String context)
Adds a directory to be served from the a specified context as if it were a standard HTTP server. |
SubscriptionManager |
getSubscriptionManager()
Returns the servers SubscriptionManager. |
boolean |
isStarted()
Identifies whether the server is currently started or not |
void |
setDefaultHeader(String name,
String value)
Sets the value of a default HTTP header for synchronous responses. |
void |
setDefaultPushHeader(String name,
String value)
Sets the value of a default HTTP header for asynchronous push responses. |
void |
start()
Starts the server |
void |
stop()
Stops the server |
| Methods inherited from interface com.streamhub.api.Publisher |
|---|
publish |
| Method Detail |
|---|
void start()
Note this method is non-blocking
void stop()
throws IOException
This method will block until all the connections have been forcibly closed and internal threads shutdown
IOExceptionboolean isStarted()
true if the server is currently started and running,
false if it has not been started or has been stoppedSubscriptionManager getSubscriptionManager()
SubscriptionManager.
The SubscriptionManager provides the core publish and subscribe
listening capabilities of the server.
Use SubscriptionManager.addPublishListener(PublishListener) to
receive callbacks when a client publishes a message to the server.
Use SubscriptionManager.addSubscriptionListener(SubscriptionListener) to
receive callbacks when a client subscribes to a topic.
It is recommended to call this method after starting the server using start()
SubscriptionManager associated with this servervoid addStaticContent(File directory)
/ as if it were
a standard HTTP server. This allows static content, for example HTML pages,
to be retrieved via a web browser.
Although StreamHub is capable of serving normal static content it was primarily designed as a Comet and HTTP Push server. For a live website or application it is recommended to serve static content from a standard HTTP Web server such as Apache or IIS.
directory - the directory on the local filesytem to make available via the webaddStaticContent(File, String)
void addStaticContent(File directory,
String context)
Although StreamHub is capable of serving normal static content it was primarily designed as a Comet and HTTP Push server. For a live website or application it is recommended to serve static content from a standard HTTP Web server such as Apache or IIS.
directory - the directory on the local filesytem to make available via the webcontext - the context to serve the directory under. For example using a context
of site would make content available under
http://serverurl/site/addStaticContent(File)
void setDefaultPushHeader(String name,
String value)
name - the name of the headervalue - the value of the header
void setDefaultHeader(String name,
String value)
name - the name of the headervalue - the value of the header
void addContext(String context,
com.streamhub.handler.Handler handler)
/examples/*.
Any incoming requests which match the context will be routed to the handler.
context - a context specifier string e.g. /examples/*handler - a handler which will handle requests matching the context
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||