sessions

package
v0.0.0-...-55d16bb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2017 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

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 Interface

type Interface interface {
	// The NavigateFunc function
	// is executed on each session navigate request.
	// You have to set the new current session path manually.
	// The string parameter specifies the route path.
	NavigateFunc(*Session, string)

	ShowErrorPage(*Session, string, ...bool)
	ShowNotFoundPage(*Session)
}

type RequestFunc

type RequestFunc func(s *Session, data map[string]string) error

type Session

type Session struct {
	// contains filtered or unexported fields
}

func GetSession

func GetSession(sessionID string) (s *Session, ok bool)

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

func (s *Session) CacheGet(key interface{}, vars ...func() interface{}) (interface{}, bool)

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

func (s *Session) CachePull(key interface{}, vars ...func() interface{}) (interface{}, bool)

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

func (s *Session) ClientDelete(key string)

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) ClientSet

func (s *Session) ClientSet(key string, data string)

ClientSet sets a value to the client side value store.

func (*Session) Close

func (s *Session) Close()

Close closes the socket connection and removes the session

func (*Session) CurrentPath

func (s *Session) CurrentPath() string

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

func (s *Session) DomEncryptionKey() string

DomEncryptionKey returns the unique secret DOM key

func (*Session) Get

func (s *Session) Get(key interface{}, vars ...func() interface{}) (interface{}, bool)

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

func (s *Session) InstanceID() string

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

func (s *Session) InstancePull(key interface{}, vars ...func() interface{}) (interface{}, bool)

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

func (s *Session) IsClosed() bool

IsClosed returns a boolean indicating if the session socket connection is closed.

func (*Session) IsJavaScriptLoaded

func (s *Session) IsJavaScriptLoaded(url string) bool

IsJavaScriptLoaded returns a boolean if a javascript library is already loaded.

func (*Session) IsStyleSheetLoaded

func (s *Session) IsStyleSheetLoaded(url string) bool

IsStyleSheetLoaded returns a boolean if a stylesheet is already loaded.

func (*Session) IsWebCrawler

func (s *Session) IsWebCrawler() bool

IsWebCrawler returns a boolean whenever the client is a web crawler.

func (*Session) JavaScripts

func (s *Session) JavaScripts() []string

JavaScripts returns a slice of all current loaded session javascripts.

func (*Session) LoadJavaScript

func (s *Session) LoadJavaScript(url string, vars ...string)

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

func (s *Session) LoadStyleSheet(url string)

LoadStyleSheet loads a stylesheet dynamically.

func (*Session) Navigate

func (s *Session) Navigate(path string)

Navigate the session to the given route path.

func (*Session) NavigateHome

func (s *Session) NavigateHome()

Navigate the session to the default route path. This is equivalent to: s.Navigate("/")

func (*Session) NewUniqueDomID

func (s *Session) NewUniqueDomID() string

NewUniqueDomID returns a new unique DOM ID.

func (*Session) NewUniqueId

func (s *Session) NewUniqueId() string

NewUniqueId returns a new unique ID. This ID can be used for unique template IDs...

func (*Session) OffClose

func (s *Session) OffClose(f func(s *Session))

OffClose removes the listener again

func (*Session) OnClose

func (s *Session) OnClose(f func(s *Session))

OnClose is triggered just before a session is destroyed

func (*Session) OnceClose

func (s *Session) OnceClose(f func(s *Session))

OnceClose is the same event as OnClose, but the listener is triggered only once

func (*Session) Path

func (s *Session) Path() string

Path returns the current URL path

func (*Session) Pull

func (s *Session) Pull(key interface{}, vars ...func() interface{}) (interface{}, bool)

Pull does the same as Get(), but additionally removes the value from the store if present. Use this for Flash values...

func (*Session) Reload

func (s *Session) Reload()

Reload the current session page.

func (*Session) RemoteAddr

func (s *Session) RemoteAddr() string

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

func (s *Session) SendCommand(cmd string)

SendCommand sends a javascript command to the client

func (*Session) SessionID

func (s *Session) SessionID() string

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

func (s *Session) SetCurrentPath(path string)

SetCurrentPath sets the path to the current session path.

func (*Session) SetExitMessage

func (s *Session) SetExitMessage(msg string)

SetExitMessage sets the exit message which is shown during the page unload.

func (*Session) ShowErrorPage

func (s *Session) ShowErrorPage(errorMessage string, vars ...bool)

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

func (s *Session) StyleSheets() []string

StyleSheets returns a slice of all current loaded session stylesheets.

type Sessions

type Sessions map[string]*Session

Directories

Path Synopsis
protobuf
Package protobuf is a generated protocol buffer package.
Package protobuf is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL