nodejs session 디자인

5885 단어 session
세 션 관리
{

    //    

    _data : {},    

    /**        ***/

    //    

    getSession : function(id){},

    //    

    createSession : function(){},

    //    

    replaceSession : function(source,target){},

    //    

    destorySession : function(id){},

    //    

    sharedSession : function(){},

    

    /**       ***/

    //          

    initSessionGCProcessor : function(){},

    //            

    intiSessionHeartbeatProcessor : function(){},

    //       

    pushMessageProcessor : function(id){},

}

세 션 문맥
{

    //      

    gcTime : 1000*60 *15,

    //      

    hbTime : 1000*2,

    //          

    msgMaxLength : 50

}

세 션 개체
        var session = {

            id:'xx',

            state : 1, //    

            lastTime : new Date(), //      

            _attr :{}, //  

            _msg : [], //      

            getAllAttr : function(){ return this._attr; },

            getAttr : function(key){ return this._attr[key]; }, //    

            removeAttr : function(key){ delete this._attr[key]; }, //    

            setAttr : function(key,value){  this._attr[key] = value; return this; }, //    

            write : function(msg){ this._msg.push(msg); },    //         

            getAndPushMsg : function(){ var result = this._msg; this._msg = []; return  result; }, //        

            close : function(){ this.state = 0; }, //    

            destory : function(){ this.state = -1;}, //    

            replace : function(session){ this._attr = session.getAllAttr(); }, //    

            refreshLastTime : function(){ this.lastTime = new Date(); }, //        

        };

좋은 웹페이지 즐겨찾기