package com.manage.service.webSocket;

import javax.servlet.*;
import java.io.IOException;


public class StartFilter implements Filter {

    public void destroy() {

    }

    public void doFilter(ServletRequest arg0, ServletResponse arg1,
            FilterChain arg2) throws IOException, ServletException {
        String ctx = arg0.getServletContext().getContextPath();
        if("/power".equals(ctx)|| "/".equals(ctx)){
            arg0.getRequestDispatcher("/login").forward(arg0, arg1);
        }
    }

    public void init(FilterConfig arg0) throws ServletException {
        this.startWebsocketInstantMsg();
    }

    /**
     * 启动即时聊天服务
     */
    public void startWebsocketInstantMsg() {
        //WebSocketImpl.DEBUG = false;
        WebServer s = new WebServer(8088);
        s.start();
    }
}