models

package
v0.0.0-...-4347809 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Id         string
	Session    *melody.Session
	ClientPool *ClientPool
}

func NewClient

func NewClient(
	clientId string,
	session *melody.Session,
	clientPool *ClientPool,
) *Client

func (*Client) HandleMessage

func (c *Client) HandleMessage(message []byte) error

func (*Client) Leave

func (c *Client) Leave()

func (*Client) Write

func (c *Client) Write(message ProcessedMessage)

type ClientPool

type ClientPool struct {
	Register   chan *Client
	Unregister chan *Client
	Clients    map[string]*Client
	// contains filtered or unexported fields
}

func NewClientPool

func NewClientPool() *ClientPool

func (*ClientPool) ClientExitFromPool

func (cp *ClientPool) ClientExitFromPool(clientId string)

func (*ClientPool) DeleteClient

func (cp *ClientPool) DeleteClient(clientId string)

func (*ClientPool) GetClient

func (cp *ClientPool) GetClient(clientId string) *Client

func (*ClientPool) SendMessageToClient

func (cp *ClientPool) SendMessageToClient(clientId string, message Message)

func (*ClientPool) SetClient

func (cp *ClientPool) SetClient(clientId string, client *Client)

func (*ClientPool) Start

func (cp *ClientPool) Start() error

type Message

type Message struct {
	Id        string                 `json:"id"        mapstructure:"id"`
	SendTo    []string               `json:"send_to"   mapstructure:"send_to"`
	Type      string                 `json:"type"      mapstructure:"type"`
	Timestamp time.Time              `json:"timestamp" mapstructure:"timestamp"`
	Payload   map[string]interface{} `json:"payload"   mapstructure:"payload"`
}

type ProcessedMessage

type ProcessedMessage struct {
	Id        string                 `json:"id"        mapstructure:"id"`
	Type      string                 `json:"type"      mapstructure:"type"`
	Timestamp time.Time              `json:"timestamp" mapstructure:"timestamp"`
	Payload   map[string]interface{} `json:"payload"   mapstructure:"payload"`
}

Jump to

Keyboard shortcuts

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