text: 
  //net handle msg
  
  var _const = require("../utils/const");
  var CONST = _const.NET;
  var CONST_MSG = _const.SYS_MSG;
  var log_manager = require("../log/log");
  _log = log_manager.log.bind(log_manager,_const.LOG.DEFAULT_LOG);
  _err = log_manager.log.bind(log_manager,_const.LOG.ERR_LOG);
  
  function handler(h){
     
     this.h = h;
  }
  
  handler.prototype.sethandler = function(h){
     this.h = h;
  };
  
  handler.prototype.handle = function(msg,s){
   
     var msgid = msg[CONST.DEFAULT_MSGID];
   
     _log(s.remoteAddress + "[" + s.remotePort + "] recv msg id ---> " + msgid);
   
   
     //handle heartbeat
     if(msgid === CONST_MSG.HEARTBEAT)
     {
        //do nothing
        
        return;
     }  
  
     //we need catch app level err,to avoid internal error
     try
     {
        //invoke common first
        var common = this.h[CONST_MSG.COMMON];
        var ret;
        if(common){
           ret = common(msg,s);
           //we allow the common to modify the msg
           msgid = msg[CONST.DEFAULT_MSGID];
        }
        
        //mean do not call handler
        if(ret === true || ret === 1){
           return;
        }
        
        //invoke msgid fn
        var fn = this.h[msgid];
        
        if(fn){  
           fn(msg,s);
        }
        else
        {
           //check we have handler for such msg - system msg can have no handler
           if(!common && msgid != CONST_MSG.CONNECT && msgid != CONST_MSG.CLOSE){
              
              _log("close! no handler for this msg");
              
              //close
              s.destroy();
           }
        }        
     }
     catch(e){
        _err(e);
     }
  
  };
  
  module.exports = handler;
  
  