Documentation ¶
Index ¶
- func GetSessions(f func(sessions Sessions))
- func Init(i Interface)
- func OffCloseSession(f func(s *Session))
- func OffNewSession(f func(s *Session))
- func OnCloseSession(f func(s *Session))
- func OnNewSession(f func(s *Session))
- func Release()
- func Request(typeStr string, r RequestFunc) error
- type ClientDataCallback
- type ClientDataErrorCallback
- type Interface
- type RequestFunc
- type Session
- func (s *Session) CacheDelete(key interface{})
- func (s *Session) CacheGet(key interface{}, vars ...func() interface{}) (interface{}, bool)
- func (s *Session) CachePull(key interface{}, vars ...func() interface{}) (interface{}, bool)
- func (s *Session) CacheSet(key interface{}, value interface{})
- func (s *Session) ClientDelete(key string)
- func (s *Session) ClientGet(key string, cb ClientDataCallback, errCb ...ClientDataErrorCallback)
- func (s *Session) ClientSet(key string, data string)
- func (s *Session) Close()
- func (s *Session) CurrentPath() string
- func (s *Session) Delete(key interface{})
- func (s *Session) Dirty()
- func (s *Session) DomEncryptionKey() string
- func (s *Session) Get(key interface{}, vars ...func() interface{}) (interface{}, bool)
- func (s *Session) HideLoadingIndicator()
- func (s *Session) InstanceDelete(key interface{})
- func (s *Session) InstanceGet(key interface{}, vars ...func() interface{}) (value interface{}, ok bool)
- func (s *Session) InstanceID() string
- func (s *Session) InstancePull(key interface{}, vars ...func() interface{}) (interface{}, bool)
- func (s *Session) InstanceSet(key interface{}, value interface{})
- func (s *Session) IsClosed() bool
- func (s *Session) IsJavaScriptLoaded(url string) bool
- func (s *Session) IsStyleSheetLoaded(url string) bool
- func (s *Session) IsWebCrawler() bool
- func (s *Session) JavaScripts() []string
- func (s *Session) LoadJavaScript(url string, vars ...string)
- func (s *Session) LoadStyleSheet(url string)
- func (s *Session) Navigate(path string)
- func (s *Session) NavigateHome()
- func (s *Session) NewUniqueDomID() string
- func (s *Session) NewUniqueId() string
- func (s *Session) OffClose(f func(s *Session))
- func (s *Session) OnClose(f func(s *Session))
- func (s *Session) OnceClose(f func(s *Session))
- func (s *Session) Path() string
- func (s *Session) Pull(key interface{}, vars ...func() interface{}) (interface{}, bool)
- func (s *Session) Reload()
- func (s *Session) RemoteAddr() string
- func (s *Session) ResetExitMessage()
- func (s *Session) SendCommand(cmd string)
- func (s *Session) SessionID() string
- func (s *Session) Set(key interface{}, value interface{})
- func (s *Session) SetCurrentPath(path string)
- func (s *Session) SetExitMessage(msg string)
- func (s *Session) ShowErrorPage(errorMessage string, vars ...bool)
- func (s *Session) ShowLoadingIndicator()
- func (s *Session) ShowNotFoundPage()
- func (s *Session) SocketType() socket.SocketType
- func (s *Session) StyleSheets() []string
- type Sessions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSessions ¶
func GetSessions(f func(sessions Sessions))
GetSessions calls the passed function with all current active session. This is done with a function call, because a mutex has to be locked to access the sessions map.
func Init ¶
func Init(i Interface)
Init initializes the sessions packages. This is called and handled by default by the bulldozer main package.
func OffCloseSession ¶
func OffCloseSession(f func(s *Session))
OffCloseSession removes the listener again
func OffNewSession ¶
func OffNewSession(f func(s *Session))
OffNewSession removes the listener again
func OnCloseSession ¶
func OnCloseSession(f func(s *Session))
OnCloseSession is triggered just before a session is destroyed
func OnNewSession ¶
func OnNewSession(f func(s *Session))
OnNewSession is triggered during each new session creation
func Release ¶
func Release()
Release releases this session package. This is handled by the main bulldozer package.
func Request ¶
func Request(typeStr string, r RequestFunc) error
Request registers the new request function. A previously registeres request with the same type will be overridden. This function has to be called during initialization! This is not thread safe!
Types ¶
type ClientDataCallback ¶
type ClientDataCallback func(data string)
type ClientDataErrorCallback ¶
type ClientDataErrorCallback func(err error)
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func GetSession ¶
GetSession returns a session with the given session ID. ok is false, if the session was not found.
func New ¶
func New(rw http.ResponseWriter, req *http.Request, isWebCrawler bool, vars ...string) (*Session, string, bool, error)
New creates and registers a new session, by adding it to the active session map. The session cookie is extracted from the request and the the new session is assigned to the server session. If no cookie is set, a new one will be assigned. A unique socket access token is returned with a boolean indicating if a new store session was created or if a previous store session was used. Use this token to connect to the session socket. One optional parameter can be passed, which set's the instance ID. A new instance ID is generated if no instance ID is passed or if the instance ID string length is invalid.
func (*Session) CacheDelete ¶
func (s *Session) CacheDelete(key interface{})
CacheDelete removes the cache value with the given key.
func (*Session) CacheGet ¶
CacheGet obtains the cache value. A single variadic argument is accepted, and it is optional: if a function is set, this function will be called if no value exists for the given key. Cache values, are values only saved as long as this session is in the memory cache. This cache does not survive application restarts.
func (*Session) CachePull ¶
CachePull does the same as CacheGet(), but additionally removes the value from the cache if present. Use this for Flash values...
func (*Session) CacheSet ¶
func (s *Session) CacheSet(key interface{}, value interface{})
CacheSet sets the cache value with the given key.
func (*Session) ClientDelete ¶
ClientSet removes a value from the client side value store.
func (*Session) ClientGet ¶
func (s *Session) ClientGet(key string, cb ClientDataCallback, errCb ...ClientDataErrorCallback)
ClientGet gets a value from the client side value store.
func (*Session) Close ¶
func (s *Session) Close()
Close closes the socket connection and removes the session
func (*Session) CurrentPath ¶
CurrentPath returns the current session route path.
func (*Session) Delete ¶
func (s *Session) Delete(key interface{})
Delete removes the value with the given key.
func (*Session) Dirty ¶
func (s *Session) Dirty()
Dirty sets the session values to an unsaved state, which will trigger the save trigger handler. Use this method, if you don't want to always call the Set() method for pointer values.
func (*Session) DomEncryptionKey ¶
DomEncryptionKey returns the unique secret DOM key
func (*Session) Get ¶
Get returns the session value for the given key. A single variadic argument is accepted, and it is optional: if a function is set, this function will be called if no value exists for the given key. This values are stored to the database backend.
func (*Session) HideLoadingIndicator ¶
func (s *Session) HideLoadingIndicator()
func (*Session) InstanceDelete ¶
func (s *Session) InstanceDelete(key interface{})
InstanceDelete removes the instance value with the given key.
func (*Session) InstanceGet ¶
func (s *Session) InstanceGet(key interface{}, vars ...func() interface{}) (value interface{}, ok bool)
InstanceGet obtains the instance value. This instance values exists as long as the browser tab session is present. A single variadic argument is accepted, and it is optional: if a function is set, this function will be called if no value exists for the given key.
func (*Session) InstanceID ¶
InstanceID returns the instance ID. This ID does not change during reconnections. This ID is unique for each browser tab session and is valid as long as the browser tab is open.
func (*Session) InstancePull ¶
InstancePull does the same as InstanceGet(), but additionally removes the value from the store if present. Use this for Flash values...
func (*Session) InstanceSet ¶
func (s *Session) InstanceSet(key interface{}, value interface{})
InstanceSet sets the instance value with the given key.
func (*Session) IsClosed ¶
IsClosed returns a boolean indicating if the session socket connection is closed.
func (*Session) IsJavaScriptLoaded ¶
IsJavaScriptLoaded returns a boolean if a javascript library is already loaded.
func (*Session) IsStyleSheetLoaded ¶
IsStyleSheetLoaded returns a boolean if a stylesheet is already loaded.
func (*Session) IsWebCrawler ¶
IsWebCrawler returns a boolean whenever the client is a web crawler.
func (*Session) JavaScripts ¶
JavaScripts returns a slice of all current loaded session javascripts.
func (*Session) LoadJavaScript ¶
LoadJavaScript loads a javascript file. One optional argument is allowed, which is a javascript command. This command is executed on a successfull load.
func (*Session) LoadStyleSheet ¶
LoadStyleSheet loads a stylesheet dynamically.
func (*Session) NavigateHome ¶
func (s *Session) NavigateHome()
Navigate the session to the default route path. This is equivalent to: s.Navigate("/")
func (*Session) NewUniqueDomID ¶
NewUniqueDomID returns a new unique DOM ID.
func (*Session) NewUniqueId ¶
NewUniqueId returns a new unique ID. This ID can be used for unique template IDs...
func (*Session) OnceClose ¶
OnceClose is the same event as OnClose, but the listener is triggered only once
func (*Session) Pull ¶
Pull does the same as Get(), but additionally removes the value from the store if present. Use this for Flash values...
func (*Session) RemoteAddr ¶
RemoteAddr returns the client remote address
func (*Session) ResetExitMessage ¶
func (s *Session) ResetExitMessage()
ResetExitMessage resets the exit message. This won't show any message on unload.
func (*Session) SendCommand ¶
SendCommand sends a javascript command to the client
func (*Session) SessionID ¶
SessionID returns the session ID. This session ID changes if the client loosed the connection and a reconnect is perfomed. Use this ID to access active sessions with GetSession or GetSessions.
func (*Session) Set ¶
func (s *Session) Set(key interface{}, value interface{})
Set sets the value with the given key.
func (*Session) SetCurrentPath ¶
SetCurrentPath sets the path to the current session path.
func (*Session) SetExitMessage ¶
SetExitMessage sets the exit message which is shown during the page unload.
func (*Session) ShowErrorPage ¶
ShowErrorPage shows the error message page with the error message if the user is authenticated. The error message will be also logged. One optional boolean can be set. If set to false, the error message won't be logged.
func (*Session) ShowLoadingIndicator ¶
func (s *Session) ShowLoadingIndicator()
func (*Session) ShowNotFoundPage ¶
func (s *Session) ShowNotFoundPage()
ShowNotFoundPage show the not found page.
func (*Session) SocketType ¶
func (s *Session) SocketType() socket.SocketType
SocketType returns the session's socket type
func (*Session) StyleSheets ¶
StyleSheets returns a slice of all current loaded session stylesheets.