Sockets 设置套接字超时

Sockets 设置套接字超时,sockets,jakarta-ee,primefaces,atmosphere,Sockets,Jakarta Ee,Primefaces,Atmosphere,我能够使用使用primefaces的push方法。如何控制p:socket超时事件及其时间? 我的意思是,如何设置p:sockettimeout?此外,, 当p:socket会话超时时,如何捕获事件 我正在使用与p:socket相关的以下部分代码语句 //xhtml <p:socket onMessage="handleMessage" channel="/chat" autoConnect="false" widgetVar="subscriber" /> 我找到了一个由

我能够使用使用primefaces的push方法。如何控制p:socket超时事件及其时间? 我的意思是,如何设置
p:socket
timeout?此外,, 当p:socket会话超时时,如何捕获事件

我正在使用与
p:socket
相关的以下部分代码语句

//xhtml

<p:socket onMessage="handleMessage" channel="/chat" autoConnect="false"
    widgetVar="subscriber" />

我找到了一个由两个步骤组成的解决方案。 首先,必须将servlet参数添加到
web.xml
中,并实现
PushContextListener

    <param-name>org.atmosphere.cpr.CometSupport.maxInactiveActivity</param-name>
    <param-value>9000</param-value>
根据传输值,可以触发断开连接过程

     if (transport != null && 
        (transport.equalsIgnoreCase(HeaderConfig.DISCONNECT) || 
         transport.equalsIgnoreCase(HeaderConfig.LONG_POLLING_TRANSPORT)
     )) {

    // close operation...
     }
  @Override
   public void onDisconnect(Object arg0) {

String transport = ((AtmosphereRequest) arg0).getRequest().getParameter
(HeaderConfig.X_ATMOSPHERE_TRANSPORT);
     if (transport != null && 
        (transport.equalsIgnoreCase(HeaderConfig.DISCONNECT) || 
         transport.equalsIgnoreCase(HeaderConfig.LONG_POLLING_TRANSPORT)
     )) {

    // close operation...
     }