Documentation
¶
Index ¶
- Constants
- Variables
- func Dump(err error)
- func Error(str string, args ...interface{})
- type Base
- type BaseRender
- type BaseSession
- func (session *BaseSession) Addr() net.Addr
- func (session *BaseSession) ClientUUID() uuid.UUID
- func (session *BaseSession) Close()
- func (session *BaseSession) HandleError(err error)
- func (session *BaseSession) SendBytes(data []byte) error
- func (session *BaseSession) SendPacket(pk pks.Packet) error
- func (session *BaseSession) SetClientUUID(uid uuid.UUID)
- func (session *BaseSession) SetState(state ConnectionState)
- func (session *BaseSession) SetUUID(uid uuid.UUID)
- func (session *BaseSession) Start()
- func (session *BaseSession) State() ConnectionState
- func (session *BaseSession) UUID() uuid.UUID
- func (session *BaseSession) Update(handlers []PacketHandler)
- type CallerInfo
- type ConnectionState
- type ErrorMessage
- type JSONRender
- type PacketHandler
- type Render
- type Response
- type Session
Constants ¶
View Source
const ( ErrIDJaga = iota ErrIDInternalError ErrIDProgramNotFound ErrIDProgramAlreadyRunning ErrIDConsoleNotFound ErrIDConsoleAlreadyClosed ErrIDSessionNotJoinedConsole )
View Source
const ( Version = "1.0.0" ProtocolVersion = 1 )
View Source
const ( QueryToken = "token" // ?token=jagajaga HandshakeTimeout = 10 * time.Second )
View Source
const ( MaxReceiveStack = 20 MaxSendStack = MaxReceiveStack MaxProcessData = 20 UpdateInterval = 100 * time.Millisecond // 0.1 SessionUpdateInterval = UpdateInterval )
View Source
const MaxStacksCount = 30
Variables ¶
View Source
var ( ErrJaga = &ErrorMessage{ ID: ErrIDJaga, Message: "Jagajaga", } ErrInternalError = &ErrorMessage{ ID: ErrIDInternalError, Message: "Internal error", } ErrProgramNotFound = &ErrorMessage{ ID: ErrIDProgramNotFound, Message: "A program is not found", } ErrProgramAlreadyRunning = &ErrorMessage{ ID: ErrIDProgramAlreadyRunning, Message: "A program is already running", } ErrConsoleNotFound = &ErrorMessage{ ID: ErrIDConsoleNotFound, Message: "A console is not found", } ErrConsoleAlreadyClosed = &ErrorMessage{ ID: ErrIDConsoleAlreadyClosed, Message: "A console is already closed", } ErrSessionNotJoined = &ErrorMessage{ ID: ErrIDSessionNotJoinedConsole, Message: "A session doesn't join a console", } )
View Source
var NotFoundResponse = &Base{ Status: http.StatusNotFound, Error: "Not found", }
Functions ¶
Types ¶
type Base ¶
func (Base) StatusCode ¶
type BaseRender ¶
type BaseRender struct { Render Writer http.ResponseWriter }
type BaseSession ¶
func NewBaseSession ¶
func (*BaseSession) Addr ¶
func (session *BaseSession) Addr() net.Addr
func (*BaseSession) ClientUUID ¶
func (session *BaseSession) ClientUUID() uuid.UUID
func (*BaseSession) Close ¶
func (session *BaseSession) Close()
func (*BaseSession) HandleError ¶
func (session *BaseSession) HandleError(err error)
func (*BaseSession) SendBytes ¶
func (session *BaseSession) SendBytes(data []byte) error
func (*BaseSession) SendPacket ¶
func (session *BaseSession) SendPacket(pk pks.Packet) error
SendPacket sends a encoded packet to session
func (*BaseSession) SetClientUUID ¶
func (session *BaseSession) SetClientUUID(uid uuid.UUID)
func (*BaseSession) SetState ¶
func (session *BaseSession) SetState(state ConnectionState)
func (*BaseSession) SetUUID ¶
func (session *BaseSession) SetUUID(uid uuid.UUID)
func (*BaseSession) Start ¶
func (session *BaseSession) Start()
func (*BaseSession) State ¶
func (session *BaseSession) State() ConnectionState
func (*BaseSession) UUID ¶
func (session *BaseSession) UUID() uuid.UUID
func (*BaseSession) Update ¶
func (session *BaseSession) Update(handlers []PacketHandler)
type CallerInfo ¶
func Stack ¶
func Stack(skip int, count int) (callerInfo []*CallerInfo)
type ConnectionState ¶
type ConnectionState int
const ( StateConnecting ConnectionState = iota StateConnected StateDisconnected )
type ErrorMessage ¶
type JSONRender ¶
type JSONRender struct {
*BaseRender
}
func NewJSONRender ¶
func NewJSONRender(w http.ResponseWriter) *JSONRender
func (*JSONRender) NotFound ¶
func (render *JSONRender) NotFound() error
func (*JSONRender) Write ¶
func (render *JSONRender) Write(res Response) error
type PacketHandler ¶
type Session ¶
type Session interface { // Addr returns client addr Addr() net.Addr // UUID returns uuid UUID() uuid.UUID SetUUID(uuid.UUID) ClientUUID() uuid.UUID SetClientUUID(uuid.UUID) State() ConnectionState SetState(ConnectionState) Update([]PacketHandler) Close() SendPacket(pks.Packet) error SendBytes([]byte) error }
Click to show internal directories.
Click to hide internal directories.