Interface IFilter
- All Known Implementing Classes:
SFSExtensionFilter
public interface IFilter
Overview
If you are familiar with the Java Servlet API this will probably look familiar. Extension Filters in SmartFoxServer are inspired to servlet filters and they serve a similar purpose: they execute in chain and they can be used to log, filter, or handle specific requests/events before they get to the Extension itself.The advantage of pluggable Filters is that they don't get in the way of your Extension code, their execution order can be altered and they can even stop the execution flow if necessary. An example of this could be a custom ban filter where User credentials are checked against a black list before the request is passed to your Login Handler. Another example of usage would be logging or filtering public and private messages.
-
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()This is invoked when the Extension is destroyedhandleClientRequest(String requestId, User sender, ISFSObject params) Handles a client requesthandleServerEvent(ISFSEvent event) Handles a server side eventvoidinit(SFSExtension ext) Initialize the Filter
-
Method Details
-
init
Initialize the Filter- Parameters:
ext- a reference to the related Extension
-
destroy
void destroy()This is invoked when the Extension is destroyed -
handleClientRequest
FilterAction handleClientRequest(String requestId, User sender, ISFSObject params) throws SFSException Handles a client request- Parameters:
requestId- the request idsender- the sender of the requestparams- the parameters of the request- Returns:
- the action returned determines if the FilterChain can continue its flow or it must stop
- Throws:
SFSException- See Also:
-
handleServerEvent
Handles a server side event- Parameters:
event- the event- Returns:
- the action returned determines if the FilterChain can continue its flow or it must stop
- Throws:
SFSException
-