|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xmlBlaster.protocol.http.HttpPushHandler
public class HttpPushHandler
This handles and hides the different http push modes when sending
data back to the browser through method update().
Push mode works with keeping a permanent http connection
Nested Class Summary | |
---|---|
private class |
HttpPushHandler.HttpPingThread
Ping the browser, to avoid that the web server or the browser closes the http connection after a vendor specific timeout. |
Field Summary | |
---|---|
private boolean |
browserIsReady
Check it the browser is ready to accept more messages |
private I_Callback |
callbackInterceptor
|
private boolean |
closed
Current http connection state |
private boolean |
firstPush
|
private boolean |
handlesMultipart
handlesMultipart is true for netscape browser |
private java.lang.String |
head
The header of the HTML page |
private static java.util.logging.Logger |
log
|
private java.lang.String |
ME
|
private javax.servlet.ServletOutputStream |
outMulti
|
private java.io.PrintWriter |
outPlain
|
private long |
PING_INTERVAL
Ping the browser every 10 seconds. |
private HttpPushHandler.HttpPingThread |
pingThread
Check browser and holds the http connection |
private java.util.Vector |
pushQueue
Queue to hold messages (class PushDataItem) until the browser is ready for them |
private javax.servlet.http.HttpServletRequest |
req
|
private javax.servlet.http.HttpServletResponse |
res
|
private java.lang.String |
sessionId
|
private java.lang.String |
tail
The tail of the HTML page |
private I_XmlBlasterAccess |
xmlBlasterAccess
|
Constructor Summary | |
---|---|
HttpPushHandler(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.lang.String sessionId,
java.lang.String loginName,
I_XmlBlasterAccess xmlBlasterAccess)
Use this constructor if you are too lazy to pass a HTML header, a default will be used. |
Method Summary | |
---|---|
static java.lang.String |
alert(java.lang.String text)
Display a popup alert message containing the error text. |
void |
cleanup()
Delegates the cleanup call to HttpPushHandler |
boolean |
closed()
check's whether the HTTP connection is closed or not |
private boolean |
doesHandleMultipart()
Determine if the browser can handle multipart pushs. |
I_XmlBlasterAccess |
getXmlBlasterAccess()
|
private void |
initialize(java.lang.String head,
java.lang.String tail)
|
boolean |
isBrowserReady()
check's whether the browser is ready to accept more messages or not [if (parent.browserReady != null) parent.browserReady();]. |
void |
message(java.lang.String text)
Calls the message method in the parentframe of the callback frame. |
void |
ping(java.lang.String state)
calls the ping method in the parentframe of the callback frame The data must be Javascript code |
void |
pong()
This is the browser response for our previous ping. |
void |
push(PushDataItem item)
Updating data to the browser (callback/push mode). |
private void |
pushToBrowser()
Pushing messages in the queue to the browser |
void |
setBrowserIsReady(boolean ready)
|
void |
setClosed(boolean closed)
|
void |
setProxyInterceptor(I_Callback interceptor)
If you implement I_ProxyInterceptor and register it here, your update() implementation is called and may manipulate the received message from xmlBlaster before it is sent to the browser. |
void |
shutdownBrowserConnection()
Don't forget to call this method when you want to close the connection. |
void |
startPing()
|
java.lang.String |
update(java.lang.String sessionId,
UpdateKey updateKey,
byte[] content,
UpdateQos updateQos)
Pushes received message back to browser or applet. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.lang.String ME
private static java.util.logging.Logger log
private final long PING_INTERVAL
private I_XmlBlasterAccess xmlBlasterAccess
private I_Callback callbackInterceptor
private javax.servlet.http.HttpServletRequest req
private javax.servlet.http.HttpServletResponse res
private java.lang.String sessionId
private boolean closed
private javax.servlet.ServletOutputStream outMulti
private java.io.PrintWriter outPlain
private java.lang.String head
private java.lang.String tail
private boolean browserIsReady
private boolean handlesMultipart
private HttpPushHandler.HttpPingThread pingThread
private java.util.Vector pushQueue
private boolean firstPush
Constructor Detail |
---|
public HttpPushHandler(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.lang.String sessionId, java.lang.String loginName, I_XmlBlasterAccess xmlBlasterAccess) throws javax.servlet.ServletException, java.io.IOException
req
- The request objectres
- The response objectsessionId
- The browser idloginName
- For loggin onlyxmlBlasterAccess
- Not yet logged in
javax.servlet.ServletException
java.io.IOException
Method Detail |
---|
public I_XmlBlasterAccess getXmlBlasterAccess()
private void initialize(java.lang.String head, java.lang.String tail) throws java.io.IOException
java.io.IOException
public void shutdownBrowserConnection()
public void setProxyInterceptor(I_Callback interceptor)
interceptor
- Your optional implementationpublic void cleanup()
public void startPing() throws javax.servlet.ServletException, java.io.IOException
javax.servlet.ServletException
java.io.IOException
public boolean closed()
public void setClosed(boolean closed)
public final boolean isBrowserReady()
public void setBrowserIsReady(boolean ready)
private boolean doesHandleMultipart() throws java.io.IOException
java.io.IOException
public void push(PushDataItem item) throws javax.servlet.ServletException, java.io.IOException
str
-
javax.servlet.ServletException
java.io.IOException
private void pushToBrowser() throws javax.servlet.ServletException, java.io.IOException
javax.servlet.ServletException
java.io.IOException
public java.lang.String update(java.lang.String sessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos)
Browser: Calls the update method in the parentframe of the callback frame The data must be Javascript code
Applet: The callbacks are java-serialized Map for key/qos etc.
update
in interface I_Callback
sessionId
- The session ID specified by the client which registered the callback.
You can specify a cbSessionId during connection (with ConnectQos)
and this is bounced back here so you can authenticate the message.updateKey
- The arrived key containing the topic namecontent
- The arrived message content. This is your payload.I_XmlBlasterAccess
public static final java.lang.String alert(java.lang.String text)
text
- The error textpublic void message(java.lang.String text)
text
- This must be Javascript code (usually a message string)public void ping(java.lang.String state) throws javax.servlet.ServletException, java.io.IOException
state
- The string "refresh"javax.servlet.ServletException
java.io.IOException
public void pong()
|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |