sockdx

package
v0.0.0-...-8c2001a Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MESSAGE_SERVER_DIRECT    = "server_direct"
	MESSAGE_SERVER_BROADCAST = "server_broadcast"
	MESSAGE_SERVER_PUBLISH   = "server_publish"

	MESSAGE_CLIENT_DIRECT    = "client_direct"
	MESSAGE_CLIENT_BROADCAST = "client_broadcast"
	MESSAGE_CLIENT_PUBLISH   = "client_publish"

	MESSAGE_CLIENT_SYSTEM         = "client_system"
	MESSAGE_SERVER_SYSTEM         = "server_system"
	MESSAGE_CLIENT_FULL_BROADCAST = "client_full_broadcast"
)
View Source
const ROOM_PLUG_DEV = "plugs_dev"
View Source
const ROOM_SYS_DATA = "sys.data"
View Source
const ROOM_SYS_USERS = "sys.users"
View Source
const TAG_CONSOLE_CONN = "sys.console_conn"
View Source
const TAG_REALUSER = "sys.real_user"

Variables

View Source
var (
	ErrRoomNotFound = errors.New("room not found")
	ErrConnNotFound = errors.New("conn not found")
	ErrConnClosed   = errors.New("conn closed")
)

Functions

This section is empty.

Types

type Conn

type Conn interface {
	Id() int64
	Write([]byte) error
	Close() error
	Read() ([]byte, error)
}

type ConnOptions

type ConnOptions struct {
	NameSpace string
	Room      string
	Conn      Conn
	Expiry    int
	Tags      []string
}

type DataSheetSyncer

type DataSheetSyncer interface {
	PushSheetNewRow(source, tenantId, groupId string, sheetId int64, ids []int64, data any) error
	PushSheetUpdateRow(source, tenantId, groupId string, sheetId int64, ids []int64, data any) error
	PushSheetDeleteRow(source, tenantId, groupId string, sheetId int64, ids []int64) error
}

type DataSyncer

type DataSyncer interface {
	DataTableSyncer
	DataSheetSyncer
}

type DataTableSyncer

type DataTableSyncer interface {
	PushNewRow(source, tenantId, groupId, table string, ids []int64, data any) error
	PushUpdateRow(source, tenantId, groupId, table string, ids []int64, data any) error
	PushDeleteRow(source, tenantId, groupId, table string, ids []int64) error
}

type Hub

type Hub interface {
	GetSockd() SockdCore
	GetDataSyncer() DataSyncer
	GetUserSyncer() UserSyncer
}

type Message

type Message struct {
	XID         string          `json:"xid,omitempty"`
	Room        string          `json:"room,omitempty"`
	Type        string          `json:"type,omitempty"`
	ServerIdent string          `json:"server_ident,omitempty"`
	Payload     json.RawMessage `json:"payload,omitempty"`

	TargetIds   []int64  `json:"target_ids,omitempty"`
	TargetTags  []string `json:"target_tags,omitempty"`
	IgnoreConns []int64  `json:"ignore_conns,omitempty"`
	FromId      int64    `json:"from_id,omitempty"`
}

func (*Message) JSON

func (m *Message) JSON() ([]byte, error)

type Options

type Options struct {
	ServerIdent string
	Syncer      PeerSync
	SysHelper   SystemHelper
	Logger      zerolog.Logger
}

type PeerSync

type PeerSync interface {
	SyncMessage(ns, room, mtype string, payload any) error
	SyncOperation(ns, room, operation string, payload any) error
}

type PollResponse

type PollResponse struct {
	Messages    map[int64][][]byte
	ExtraEvents []any
}

type Sockd

type Sockd interface {
	SockdCore
	SockdControl
}

type SockdControl

type SockdControl interface {
	LocalListConns(ns string) (map[int64]string, error)
	LocalListRoomConns(ns, room string) (map[int64][]string, error)
	LocalKickRoomConn(ns, room string, cid int64) error
	LocalCloseRoom(ns, room string) error
}

type SockdCore

type SockdCore interface {
	NewConnection(opts ConnOptions) error

	SendDirect(ns, room string, connId int64, payload []byte) error
	SendDirectBatch(ns, room string, conns []int64, payload []byte) error

	SendBroadcast(ns, room string, ignores []int64, payload []byte) error
	SendTagged(ns, room string, tags []string, ignores []int64, payload []byte) error
	RoomUpdateTags(ns, roomId string, opts UpdateTagOptions) error

	Poll(ns, roomId string, max, min int64) (*PollResponse, error)
}

type SystemHelper

type SystemHelper interface {
	ParseRoomTkt(tenantId, payload string) (*claim.RoomTagTkt, error)
}

type UpdateTagOptions

type UpdateTagOptions struct {
	Id         int64
	AddTags    []string
	RemoveTags []string
	ClearOld   bool
}

type UserSyncer

type UserSyncer interface {
	NotifyUser(msg *entities.UserMessage) error
	NotifyMessageRead(tenantId, user string, msgIds []int) error
	NotifyMessageDelete(tenantId, user string, msgIds []int) error
}

Jump to

Keyboard shortcuts

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