本文整理汇总了Java中org.jivesoftware.openfire.interceptor.PacketInterceptor类的典型用法代码示例。如果您正苦于以下问题:Java PacketInterceptor类的具体用法?Java PacketInterceptor怎么用?Java PacketInterceptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PacketInterceptor类属于org.jivesoftware.openfire.interceptor包,在下文中一共展示了PacketInterceptor类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: start
import org.jivesoftware.openfire.interceptor.PacketInterceptor; //导入依赖的package包/类
public void start() {
// Retrieve instance of StatisticsManager
statisticsManager = StatisticsManager.getInstance();
// Register a packet listener so that we can track packet traffic.
packetInterceptor = new PacketInterceptor() {
public void interceptPacket(Packet packet, Session session, boolean incoming,
boolean processed)
{
// Only track processed packets so that we don't count them twice.
if (processed) {
packetCount.incrementAndGet();
}
}
};
InterceptorManager.getInstance().addInterceptor(packetInterceptor);
// Register all statistics.
addServerToServerStatistic();
addActiveSessionsStatistic();
addPacketStatistic();
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:23,代码来源:StatisticsModule.java
示例2: start
import org.jivesoftware.openfire.interceptor.PacketInterceptor; //导入依赖的package包/类
/**
* Start handling the added interceptors.
* If it is started you could not remove or add interceptors
*/
public void start() {
Log.debug("Start handling message interceptors for gateway " + _subdomain);
_isRunning = true;
for (PacketInterceptor interceptor : _interceptors) {
_iManager.addInterceptor(interceptor);
}
}
开发者ID:surevine,项目名称:openfire-bespoke,代码行数:12,代码来源:AbstractInterceptorHandler.java
示例3: stop
import org.jivesoftware.openfire.interceptor.PacketInterceptor; //导入依赖的package包/类
/**
* Stop handling the added interceptors.
*/
public void stop() {
Log.debug("Stop handling message interceptors for gateway " + _subdomain);
if (!_isRunning)
return;
_isRunning = false;
for (PacketInterceptor interceptor : _interceptors) {
_iManager.removeInterceptor(interceptor);
}
}
开发者ID:surevine,项目名称:openfire-bespoke,代码行数:14,代码来源:AbstractInterceptorHandler.java
示例4: run
import org.jivesoftware.openfire.interceptor.PacketInterceptor; //导入依赖的package包/类
/**
* Run a test against the domain.
* @return K-V pairs of debug information.
* @throws Exception On error.
*/
public Map<String, String> run() throws Exception {
waitUntil = new Semaphore(0);
Map<String, String> results = new HashMap<>();
final DomainPair pair = new DomainPair(XMPPServer.getInstance().getServerInfo().getXMPPDomain(), domain);
// Tear down existing routes.
final SessionManager sessionManager = SessionManager.getInstance();
for (final Session incomingServerSession : sessionManager.getIncomingServerSessions( domain ) )
{
incomingServerSession.close();
}
final Session outgoingServerSession = sessionManager.getOutgoingServerSession( pair );
if ( outgoingServerSession != null )
{
outgoingServerSession.close();
}
final IQ pingRequest = new IQ( Type.get );
pingRequest.setChildElement( "ping", IQPingHandler.NAMESPACE );
pingRequest.setFrom( pair.getLocal() );
pingRequest.setTo( domain );
// Intercept logging.
final StringBuilder logs = new StringBuilder();
Appender appender = interceptLogging(logs);
// Intercept packets.
final PacketInterceptor interceptor = new S2SInterceptor( pingRequest );
InterceptorManager.getInstance().addInterceptor(interceptor);
// Send ping.
try
{
Log.info( "Sending server to server ping request to " + domain );
XMPPServer.getInstance().getIQRouter().route( pingRequest );
// Wait for success or exceed socket timeout.
waitUntil.tryAcquire( RemoteServerManager.getSocketTimeout(), TimeUnit.MILLISECONDS );
// Check on the connection status.
logSessionStatus();
// Prepare response.
results.put( "certs", getCertificates() );
results.put( "stanzas", interceptor.toString() );
results.put( "logs", logs.toString() );
return results;
}
finally
{
// Cleanup
InterceptorManager.getInstance().removeInterceptor( interceptor );
Logger.getRootLogger().removeAppender( appender );
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:63,代码来源:S2STestService.java
示例5: start
import org.jivesoftware.openfire.interceptor.PacketInterceptor; //导入依赖的package包/类
/**
* Resets all counters, and starts counting.
*/
public void start() {
// Register a packet listener so that we can track packet traffic.
interceptor = new PacketInterceptor() {
public void interceptPacket(final Packet packet,
final Session session, final boolean incoming,
final boolean processed) {
if (!processed) {
// don't count packets twice!
return;
}
stanza.incrementAndGet();
if (packet instanceof Message) {
message.incrementAndGet();
}
if (packet instanceof Presence) {
presence.incrementAndGet();
}
if (packet instanceof IQ) {
iq.incrementAndGet();
switch (((IQ) packet).getType()) {
case get:
iqGet.incrementAndGet();
break;
case set:
iqSet.incrementAndGet();
break;
case result:
iqResult.incrementAndGet();
break;
case error:
iqError.incrementAndGet();
break;
}
}
}
};
// reset counters
stanza.set(0);
message.set(0);
presence.set(0);
iq.set(0);
iqGet.set(0);
iqSet.set(0);
iqResult.set(0);
iqError.set(0);
// register listener
InterceptorManager.getInstance().addInterceptor(interceptor);
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:61,代码来源:PacketCounter.java
示例6: addInterceptor
import org.jivesoftware.openfire.interceptor.PacketInterceptor; //导入依赖的package包/类
/**
* Add a interceptor to the let it handled by the abstract implementation
* The handle must not be started. You have to stop() until you could add
* new interceptors.
*
* @param interceptor
* @return true if it successfully added, otherwise false
*/
protected boolean addInterceptor(PacketInterceptor interceptor) {
if (_isRunning) {
return false;
}
return _interceptors.add(interceptor);
}
开发者ID:surevine,项目名称:openfire-bespoke,代码行数:15,代码来源:AbstractInterceptorHandler.java
示例7: removeInterceptor
import org.jivesoftware.openfire.interceptor.PacketInterceptor; //导入依赖的package包/类
/**
* Remove a interceptor from abstract implementation The handle must not be
* started. You have to stop() until you could remove interceptors.
*
* @param interceptor
* @return true if it successfully added, otherwise false
*/
protected boolean removeInterceptor(PacketInterceptor interceptor) {
if (_isRunning) {
return false;
}
return _interceptors.remove(interceptor);
}
开发者ID:surevine,项目名称:openfire-bespoke,代码行数:14,代码来源:AbstractInterceptorHandler.java
注:本文中的org.jivesoftware.openfire.interceptor.PacketInterceptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论