mimi

package module
v0.0.0-...-8016c1d Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2018 License: MIT Imports: 11 Imported by: 0

README

mimi

developing now...

License

These codes are licensed under MIT License.

See LICENSE file.

Special Thanks

Design Reference

Documentation

Index

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

func Dump

func Dump(err error)

func Error

func Error(str string, args ...interface{})

Error logs errors

Types

type Base

type Base struct {
	Status int    `json:"status"`
	Error  string `json:"error"`
}

func (Base) StatusCode

func (base Base) StatusCode() int

type BaseRender

type BaseRender struct {
	Render

	Writer http.ResponseWriter
}

type BaseSession

type BaseSession struct {
	Conn *websocket.Conn
	// contains filtered or unexported fields
}

func NewBaseSession

func NewBaseSession(conn *websocket.Conn, uid uuid.UUID, cid uuid.UUID) BaseSession

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

type CallerInfo struct {
	PackageName  string
	FunctionName string
	FileName     string
	FileLine     int
}

func Stack

func Stack(skip int, count int) (callerInfo []*CallerInfo)

type ConnectionState

type ConnectionState int
const (
	StateConnecting ConnectionState = iota
	StateConnected
	StateDisconnected
)

type ErrorMessage

type ErrorMessage struct {
	ID      int
	Message string
}

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 PacketHandler interface {
	HandlePacket(session Session, pk pks.Packet)
}

type Render

type Render interface {
	Write(res Response) error
	NotFound() error
}

type Response

type Response interface {
	StatusCode() int
}

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
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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