realtime

package
v0.0.0-...-867eee7 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2019 License: LGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeliveryTaskFunc

type DeliveryTaskFunc func(delay time.Duration, key interface{}, data interface{})

type EventHandleFunc

type EventHandleFunc func(ss *Session, data interface{})

func (EventHandleFunc) HandleEvent

func (fn EventHandleFunc) HandleEvent(ss *Session, data interface{})

type EventHandler

type EventHandler interface {
	HandleEvent(ss *Session, data interface{})
}

type Room

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

func (*Room) Broadcast

func (r *Room) Broadcast(event string, payload interface{}, expect ...SessionId)

func (*Room) Count

func (r *Room) Count() int

func (*Room) Join

func (r *Room) Join(id SessionId)

func (*Room) Members

func (r *Room) Members() []SessionId

func (*Room) Name

func (r *Room) Name() string

func (*Room) Remove

func (r *Room) Remove(id SessionId)

type RpcHandleFunc

type RpcHandleFunc func(ss *Session, p gson) (result interface{}, err error)

func (RpcHandleFunc) HandleRpc

func (fn RpcHandleFunc) HandleRpc(ss *Session, p gson) (result interface{}, err error)

type RpcHandler

type RpcHandler interface {
	HandleRpc(ss *Session, p gson) (result interface{}, err error)
}

type Server

type Server struct {
	SessionKeepTime         time.Duration // 断线, 回话维持时间
	KeepMessageCount        int           // 断线保留的消息数量
	BeforeAcceptSession     func(ss *Session) (err error)
	AfterAcceptSession      func(ss *Session) (err error)
	BeforeDispatchUserEvent func(ss *Session, event string) (err error)
	BeforeDispatchUserRpc   func(ss *Session, method string) (err error)
	OnSessionLost           func(ss *Session)
	// contains filtered or unexported fields
}

func (*Server) HttpHandler

func (s *Server) HttpHandler() http.Handler

用于绑定外部http server

func (*Server) RegisterEventHandler

func (s *Server) RegisterEventHandler(mp map[string]EventHandler)

func (*Server) RegisterRpcHandler

func (s *Server) RegisterRpcHandler(mp map[string]RpcHandler)

func (*Server) RegisterTaskHandler

func (s *Server) RegisterTaskHandler(taskName string, handler func(data interface{})) DeliveryTaskFunc

func (*Server) RemoveSession

func (s *Server) RemoveSession(id SessionId)

func (*Server) RoomByName

func (s *Server) RoomByName(name string) *Room

func (*Server) RoomExist

func (s *Server) RoomExist(name string) bool

func (*Server) SessionById

func (s *Server) SessionById(id SessionId) (ss *Session, ok bool)

type Session

type Session struct {
	Data interface{} // 业务数据存放
	// contains filtered or unexported fields
}

func (*Session) Emit

func (ss *Session) Emit(event string, data interface{}, room ...string)

func (*Session) Id

func (ss *Session) Id() SessionId

func (*Session) InRoom

func (ss *Session) InRoom(name string) bool

func (*Session) Read

func (ss *Session) Read() (data gson, err error)

func (*Session) Rooms

func (ss *Session) Rooms() []*Room

type SessionId

type SessionId string

Jump to

Keyboard shortcuts

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