Documentation
¶
Index ¶
- type AsyncSender
- type AsyncSenderCloser
- type Context
- func (c *Context) GetRequest(requestID int64) (channel chan<- dtos.WebSocketMessage, ok bool)
- func (c *Context) GetSessionData(key string) (data interface{}, ok bool)
- func (c *Context) NewRequest() (int64, <-chan dtos.WebSocketMessage)
- func (c *Context) OnClose()
- func (c *Context) SetSessionData(key string, data interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AsyncSender ¶
type AsyncSender interface {
SendAsync(msg dtos.WebSocketMessage) <-chan error
}
AsyncSender allows asynchronous sending of messages
type AsyncSenderCloser ¶
type AsyncSenderCloser interface { AsyncSender Close() }
AsyncSenderCloser represents a type that allows asynchronous sending of messages and closing the connection.
type Context ¶
type Context struct { AsyncSenderCloser // contains filtered or unexported fields }
Context stores session context
func NewContext ¶
func NewContext(c AsyncSenderCloser) *Context
NewContext constructs a new valid Context object
func (*Context) GetRequest ¶
func (c *Context) GetRequest(requestID int64) (channel chan<- dtos.WebSocketMessage, ok bool)
GetRequest retrieves the channel associated with the request identified by the provided requestID. If the request has not been found or has already been retrieved the ok return value is set to false.
func (*Context) GetSessionData ¶
GetSessionData retrieves a value from this session context
func (*Context) NewRequest ¶
func (c *Context) NewRequest() (int64, <-chan dtos.WebSocketMessage)
NewRequest registers a new request to be sent. The returned channel is used to receive the incoming response. The ID returned from this function has to be used as the value for WebSocketMessage.RequestID.
func (*Context) OnClose ¶
func (c *Context) OnClose()
OnClose is called when the underlying connection is closed. It performs the necessary context cleanup.
func (*Context) SetSessionData ¶
SetSessionData stores a value in this session context