event

package
v1.13.7 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

the core package provides basic functionality to all the major components of the code

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockingMockEventChannel

type BlockingMockEventChannel struct {
	*MockEventChannel
	// contains filtered or unexported fields
}

BlockingMockEventChannel essentially does the same thing as a MockEventChannel except when it's out of QueuedEvents then it just blocks until Disconnect() is called.

func NewBlockingMockEventChannel

func NewBlockingMockEventChannel() *BlockingMockEventChannel

func (*BlockingMockEventChannel) Disconnect

func (ec *BlockingMockEventChannel) Disconnect()

func (*BlockingMockEventChannel) OnConnect

func (ec *BlockingMockEventChannel) OnConnect()

func (*BlockingMockEventChannel) Ready

func (ec *BlockingMockEventChannel) Ready() <-chan bool

func (*BlockingMockEventChannel) ReceiveEvent

func (ec *BlockingMockEventChannel) ReceiveEvent() (Event, error)

type DefaultEvent

type DefaultEvent struct {
	EventType   string `json:"event"`
	EventValue  any    `json:"value"`
	EventUserID string `json:"userid"`
	EventID     string `json:"eventid"`
}

Event is the basic struct for sending and receiving messages over the websockets

func (*DefaultEvent) ID

func (e *DefaultEvent) ID() string

func (*DefaultEvent) SetID

func (e *DefaultEvent) SetID(id string)

func (*DefaultEvent) SetType

func (e *DefaultEvent) SetType(t string)

func (*DefaultEvent) SetUser

func (e *DefaultEvent) SetUser(id string)

func (*DefaultEvent) SetValue

func (e *DefaultEvent) SetValue(v any)

func (*DefaultEvent) Type

func (e *DefaultEvent) Type() string

func (*DefaultEvent) User

func (e *DefaultEvent) User() string

func (*DefaultEvent) Value

func (e *DefaultEvent) Value() any

type DefaultEventChannel

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

DefaultEventChannel is a thin wrapper around a ReadWriteCloser

func (*DefaultEventChannel) Close

func (ec *DefaultEventChannel) Close() error

func (*DefaultEventChannel) ID

func (ec *DefaultEventChannel) ID() string

func (*DefaultEventChannel) OnConnect

func (ec *DefaultEventChannel) OnConnect()

func (*DefaultEventChannel) ReceiveEvent

func (ec *DefaultEventChannel) ReceiveEvent() (Event, error)

func (*DefaultEventChannel) SendEvent

func (ec *DefaultEventChannel) SendEvent(evt Event) error

type Event

type Event interface {
	Type() string
	Value() any
	User() string
	ID() string
	SetType(string)
	SetValue(any)
	SetUser(string)
	SetID(string)
}

func EmptyEvent

func EmptyEvent() Event

func ErrorEvent

func ErrorEvent(msg string) Event

ErrorEvent is a special case of an Event

func EventFromJSON

func EventFromJSON(data []byte) (Event, error)

func FrameEvent

func FrameEvent(value any) Event

func NewEvent

func NewEvent(t string, value any) Event

func NopEvent

func NopEvent() Event

NopEvent signals to the server to do nothing (in particular, don't send to clients)

type EventChannel

type EventChannel interface {
	SendEvent(evt Event) error
	ReceiveEvent() (Event, error)
	OnConnect()
	Close() error
	ID() string
}

func NewDefaultEventChannel

func NewDefaultEventChannel(ws io.ReadWriteCloser) EventChannel

type MockEventChannel

type MockEventChannel struct {
	QueuedEvents []Event

	SavedEvents []Event

	Closed bool
	// contains filtered or unexported fields
}

func NewMockEventChannel

func NewMockEventChannel() *MockEventChannel

func (*MockEventChannel) Close

func (ec *MockEventChannel) Close() error

func (*MockEventChannel) GetRoomID

func (ec *MockEventChannel) GetRoomID() string

func (*MockEventChannel) ID

func (ec *MockEventChannel) ID() string

func (*MockEventChannel) OnConnect

func (ec *MockEventChannel) OnConnect()

func (*MockEventChannel) ReceiveEvent

func (ec *MockEventChannel) ReceiveEvent() (Event, error)

func (*MockEventChannel) SendEvent

func (ec *MockEventChannel) SendEvent(evt Event) error

func (*MockEventChannel) SetRoomID

func (ec *MockEventChannel) SetRoomID(s string)

type TwoWayMockEventChannel

type TwoWayMockEventChannel struct {
	*BlockingMockEventChannel
	// contains filtered or unexported fields
}

func NewTwoWayMockEventChannel

func NewTwoWayMockEventChannel() *TwoWayMockEventChannel

func (*TwoWayMockEventChannel) Disconnect

func (ec *TwoWayMockEventChannel) Disconnect()

func (*TwoWayMockEventChannel) Flush

func (ec *TwoWayMockEventChannel) Flush()

func (*TwoWayMockEventChannel) ReceiveEvent

func (ec *TwoWayMockEventChannel) ReceiveEvent() (Event, error)

func (*TwoWayMockEventChannel) SendEvent

func (ec *TwoWayMockEventChannel) SendEvent(evt Event) error

func (*TwoWayMockEventChannel) SimulateEvent

func (ec *TwoWayMockEventChannel) SimulateEvent(evt Event)

Jump to

Keyboard shortcuts

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