bakuteh

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACTION_INIT  = "init"
	ACTION_ERROR = "error"
	ACTION_CLOSE = "close"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionClass

type ActionClass interface {
	Register(*Server) ActionMap
}

type ActionMap

type ActionMap map[string]func(*Request)

type Bakuteh

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

func New

func New() *Bakuteh

func (*Bakuteh) HandleServer

func (bk *Bakuteh) HandleServer(path string, act ActionClass)

func (*Bakuteh) ServerWs

func (bk *Bakuteh) ServerWs(w http.ResponseWriter, r *http.Request)

type Client

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

func (*Client) Broadcast

func (cli *Client) Broadcast(msg *Message)

func (*Client) Close

func (cli *Client) Close(reason string)

func (*Client) NextRequest

func (cli *Client) NextRequest(msg Message)

func (*Client) Send

func (cli *Client) Send(msg *Message, chs ...chan error)

func (*Client) SessionGet

func (cli *Client) SessionGet(key string) interface{}

func (*Client) SessionSet

func (cli *Client) SessionSet(key string, val interface{})

type Message

type Message struct {
	ID     int         `json:"id"`
	Action string      `json:"action"`
	Data   interface{} `json:"data"`
}

type Request

type Request struct {
	Cli *Client
	Msg *Message
	// contains filtered or unexported fields
}

func (*Request) Response

func (req *Request) Response(msg Message)

func (*Request) SessionGet

func (req *Request) SessionGet(key string) interface{}

func (*Request) SessionSet

func (req *Request) SessionSet(key string, val interface{})

type Server

type Server struct {
	DelayQuit time.Duration
	// contains filtered or unexported fields
}

func (*Server) Broadcast

func (srv *Server) Broadcast(msg *Message, chs ...chan error)

func (*Server) RoomBroadcast

func (srv *Server) RoomBroadcast(room string, msg *Message, chs ...chan error)

func (*Server) RoomJoin

func (srv *Server) RoomJoin(name string, cli *Client)

func (*Server) RoomQuit

func (srv *Server) RoomQuit(name string, cli *Client)

func (*Server) Run

func (srv *Server) Run()

func (*Server) Stop

func (srv *Server) Stop()

type Signal

type Signal struct {
	Action int
	Cli    *Client
	Room   string
	Msg    *Message
	Err    chan error
}

Jump to

Keyboard shortcuts

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