exchange

package
v0.0.0-...-539d32a Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PingEvent    = "Ping"
	DataEvent    = "Data"
	WindowsEvent = "Windows"

	JoinEvent  = "Join"
	LeaveEvent = "Leave"

	ExitEvent = "Exit"

	JoinSuccessEvent = "JoinSuccess"

	ShareJoin  = "Share_JOIN"
	ShareLeave = "Share_LEAVE"
	ShareUsers = "Share_USERS"

	ActionEvent = "Action"
)
View Source
const (
	ZmodemStartEvent = "ZMODEM_START"
	ZmodemEndEvent   = "ZMODEM_END"
)

Variables

This section is empty.

Functions

func Initial

func Initial()

func Register

func Register(r *Room)

func UnRegister

func UnRegister(r *Room)

Types

type Config

type Config struct {
	// Defaults to "tcp".
	Network string
	// Addr of a single redis server instance.
	// See "Clusters" field for clusters support.
	// Defaults to "127.0.0.1:6379".
	Addr string
	// Clusters a list of network addresses for clusters.
	// If not empty "Addr" is ignored.
	Clusters []string

	Password    string
	DialTimeout time.Duration

	// MaxActive defines the size connection pool.
	// Defaults to 10.
	MaxActive int

	DBIndex int
}

type Conn

type Conn struct {
	Id string
	Stream
	// contains filtered or unexported fields
}

func WrapperUserCon

func WrapperUserCon(stream Stream) *Conn

type MetaMessage

type MetaMessage struct {
	UserId     string `json:"user_id"`
	User       string `json:"user"`
	Created    string `json:"created"`
	RemoteAddr string `json:"remote_addr"`
}

type Room

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

func CreateRoom

func CreateRoom(id string, inChan chan *RoomMessage) *Room

func GetRoom

func GetRoom(roomId string) *Room

func (*Room) Broadcast

func (r *Room) Broadcast(msg *RoomMessage)

func (*Room) Done

func (r *Room) Done() <-chan struct{}

func (*Room) Receive

func (r *Room) Receive(msg *RoomMessage)

func (*Room) Subscribe

func (r *Room) Subscribe(conn *Conn)

func (*Room) UnSubscribe

func (r *Room) UnSubscribe(conn *Conn)

type RoomManager

type RoomManager interface {
	Add(s *Room)
	Delete(s *Room)
	Get(sid string) *Room
}

type RoomMessage

type RoomMessage struct {
	Event string `json:"event"`
	Body  []byte `json:"data"`

	Meta MetaMessage `json:"meta"` // receive的信息必须携带Meta
}

func (RoomMessage) Marshal

func (m RoomMessage) Marshal() []byte

type Stream

type Stream interface {
	io.WriteCloser
	HandleRoomEvent(event string, msg *RoomMessage)
}

Jump to

Keyboard shortcuts

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