realtime

package
v0.0.0-...-fe1601c Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// BufferSize holds the queue size for broadcasting channels.
	BufferSize = 100

	// Broadcast receives messages to be broadcasted into global namespace.
	Broadcast chan string

	// ToChan broadcasting
	ToChan chan M
)

Functions

func ServeHTTP

func ServeHTTP() func(w http.ResponseWriter, r *http.Request)

ServeHTTP exposes http server handler for glue.

Types

type Client

type Client struct {
	Raw      *glue.Socket
	Channels *sync.Map
	// Channels map[string]*glue.Channel
	User *user.User
	Read chan SocketEvent
	// contains filtered or unexported fields
}

Client contains a message to be broadcasted to a channel

func (*Client) SafeWrite

func (c *Client) SafeWrite(data string)

SafeWrite to client (from nil pointers)

func (*Client) String

func (c *Client) String() string

type M

type M struct {
	Channel string
	Content string
	ID      *bson.ObjectId
}

M holds the structure to broadcast messages

type SocketEvent

type SocketEvent struct {
	Event  string                 `json:"event"`
	Params map[string]interface{} `json:"params"`
}

func (SocketEvent) Encode

func (ev SocketEvent) Encode() string

Jump to

Keyboard shortcuts

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