protected void doMessage(SipServletRequest request) throws 
            ServletException, IOException {

        request.createResponse(SipServletResponse.SC_OK).send();            

        Object message = request.getContent();
        String from = request.getFrom().getURI().toString();
        
        logger.info("from is "+ from);
        
        //A user asked to quit.
        if(message.toString().equalsIgnoreCase("/quit")) {
            sendToUser(from, "Bye");
            removeUser(from);
            return;
        }
        
        //Add user to the list
        if(!containsUser(from)) {
            sendToUser(from, "Welcome to chatroom " + serverAddress + 
                    ". Type '/quit' to exit.");
            addUser(from);
        }

        if(message.toString().equalsIgnoreCase("/who")) {
            String users = "List of users:\n";
            List<String> list = (List<String>)getServletContext().getAttribute(USER_LIST);
            for (String user : list) {
                users += user + "\n";
            }
            sendToUser(from, users);
//            removeUser(from);
            return;
        }

        //If the user is joining the chatroom silently, no message 
        //to broadcast, return. 
        if(message.toString().equalsIgnoreCase("/join")) {
            return;
        }
        
        //We could implement more IRC commands here, 
        //see http://www.mirc.com/cmds.html
        sendToAll(from, message, request.getHeader("Content-Type"));
	}
protected void doMessage ( SipServletRequest request ) throws ServletException , IOException { request . createResponse ( SipServletResponse . SC_OK ) . send ( ) ; Object message = request . getContent ( ) ; String from = request . getFrom ( ) . getURI ( ) . toString ( ) ; logger . info ( "from is " + from ) ; if ( message . toString ( ) . equalsIgnoreCase ( "/quit" ) ) { sendToUser ( from , "Bye" ) ; removeUser ( from ) ; return ; } if ( ! containsUser ( from ) ) { sendToUser ( from , "Welcome to chatroom " + serverAddress + ". Type '/quit' to exit." ) ; addUser ( from ) ; } if ( message . toString ( ) . equalsIgnoreCase ( "/who" ) ) { String users = "List of users:\n" ; List < String > list = ( List < String > ) getServletContext ( ) . getAttribute ( USER_LIST ) ; for ( String user : list ) { users += user + "\n" ; } sendToUser ( from , users ) ; return ; } if ( message . toString ( ) . equalsIgnoreCase ( "/join" ) ) { return ; } sendToAll ( from , message , request . getHeader ( "Content-Type" ) ) ; }
This is called by the container when a MESSAGE message arrives.