A server administrator can install inbound and/or outbound filters to ensure that incoming packets with questionable content are rejected and ominous outgoing packets are suppressed. 

If filters should work as a global security instance independent from plug-ins or listeners, they can be loaded as separate .jars on the server. 

In the communication chain every incoming packet passes through the inbound filters before any further processing as well as every outgoing packets passes through the outbound filters before sending to clients. 

Filters can also be used within applications instead of .jar files, for example, for validation of packets. In this case, a new class simply implements the filter interface with two simple methods:

Public class SampleFilter extends TokenFilter {

	Public void processTokenIn(FilterResponse aResponse, WebSocketConnector aConnector, Token aToken) {

		TokenServer 1Server = getServer();
		String 1Username = 1Server.getUsername(aConnector);

		if ("locked".equals(1Username)) {
			Token 1Token = 1Server.createAccessDenied(aToken);
			1Server.sendToken(aConnector, 1Token);

This example shows, how jWebSocket checks, if a user is blocked and an incoming token is rejected. The procedure is identical for outgoing token.


Learn more about WebSockets in general, get background information and gain deeper insight!

Join jWebSocket

Wether developer, designer or translator – join the jWebSocket team and grow together with our success!

Copyright © 2013 Innotrade GmbH. All rights reserved.