exchange

package
v0.0.0-...-503ec33 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

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

	PauseEvent  = "Pause"
	ResumeEvent = "Resume"

	JoinEvent  = "Join"
	LeaveEvent = "Leave"

	ExitEvent = "Exit"

	JoinSuccessEvent = "JoinSuccess"

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

	ActionEvent = "Action"

	ShareRemoveUser = "Share_REMOVE_USER"
)
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

	SentinelsHost    string
	SentinelPassword string
	SSLCa            string
	SSLCert          string
	SSLKey           string
	UseSSL           bool
}

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"`

	TerminalId string `json:"terminal_id"`
	Primary    bool   `json:"primary"`
	Writable   bool   `json:"writable"`
}

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