// NewFilestore initializes a new SessionStore backed by a file
NewFilestore initializes a new SessionStore backed by a file
// NewFilestore initializes a new SessionStore backed by a file
func NewFilestore(key, filename string) SessionStore {
	filestore := &filestore{
		key:    key,
		states: make(map[string]*MsgState),
	}
	if strings.HasPrefix(filename, "file://") {
		filestore.filename = strings.Replace(filename, "file://", "", 1)
	} else {
		filestore.filename = filename
	}
	signal.Notify(chQuit, os.Interrupt, syscall.SIGTERM)
	go func() {
		select {
		case <-chQuit:
			fmt.Println("Got signal, wrapping up")
			filestore.flushToDisk()
		}
	}()
	gob.Register(map[string]interface{}{})
	gob.Register(bson.D{})
	gob.Register(bson.M{})
	gob.Register(bson.NewObjectId())
	return filestore
}
func NewFilestore ( key , filename string ) SessionStore { filestore := & filestore { key : key , states : make ( map [ string ] * MsgState ) , } if strings . HasPrefix ( filename , " " ) { filestore . filename = strings . Replace ( filename , " " , " " , 1 ) } else { filestore . filename = filename } signal . Notify ( chQuit , os . Interrupt , syscall . SIGTERM ) go func ( ) { select { case <- chQuit : fmt . Println ( " " ) filestore . flushToDisk ( ) } } ( ) gob . Register ( map [ string ] interface { } { } ) gob . Register ( bson . D { } ) gob . Register ( bson . M { } ) gob . Register ( bson . NewObjectId ( ) ) return filestore }
NewFilestore initializes a new SessionStore backed by a file
NewFilestore initializes a new SessionStore backed by a file