stream

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2020 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Request ...
	Request = "request"
	// Response ...
	Response = "response"
	// StatusSuccess ...
	StatusSuccess = "success"
	// StatusError ...
	StatusError = "error"
	// Notify ...
	Notify = "notify"
	// Broadcast ...
	Broadcast = "broadcast"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BroadcastClient added in v0.0.15

type BroadcastClient interface {
	Broadcast(message []byte)
}

BroadcastClient ...

type Client

type Client struct {
	Ip        string
	Referer   string
	UserAgent string
	Width     int
	Height    int
	Cookie    bool
	Language  string
	Platform  string
	Location  string
	Href      string
	Send      chan []byte // message buffered channel

	Connect *websocket.Conn
	// contains filtered or unexported fields
}

Client ...

func (*Client) Close

func (c *Client) Close()

Close ...

func (*Client) Notify

func (c *Client) Notify(t, b string)

Notify ...

func (*Client) UpdateInfo

func (c *Client) UpdateInfo(msg Message)

UpdateInfo ...

func (*Client) Write

func (c *Client) Write(payload []byte) (err error)

Write ...

func (*Client) WritePump

func (c *Client) WritePump()

send message to client

type Hub

type Hub struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Hub ...

func NewHub

func NewHub() *Hub

NewHub ...

func (*Hub) AddClient

func (h *Hub) AddClient(client *Client)

AddClient ...

func (*Hub) Broadcast

func (h *Hub) Broadcast(message []byte)

Broadcast ...

func (*Hub) Clients

func (h *Hub) Clients() (clients []*Client)

Clients ...

func (*Hub) Recv

func (h *Hub) Recv(client *Client, b []byte)

Recv ...

func (*Hub) Run

func (h *Hub) Run()

Run ...

func (*Hub) Send

func (h *Hub) Send(client *Client, message []byte)

Send ...

func (*Hub) Subscribe

func (h *Hub) Subscribe(command string, f func(client IStreamClient, msg Message))

Subscribe ...

func (*Hub) Subscriber added in v0.0.15

func (h *Hub) Subscriber(command string) (f func(client IStreamClient, msg Message))

Subscriber ...

func (*Hub) UnSubscribe

func (h *Hub) UnSubscribe(command string)

UnSubscribe ...

type IStreamClient added in v0.1.1

type IStreamClient interface {
	Write(payload []byte) error
	Notify(t, b string)
}

IStreamClient ...

type Message added in v0.0.9

type Message struct {
	Id      uuid.UUID              `json:"id"`
	Command string                 `json:"command"`
	Payload map[string]interface{} `json:"payload"`
	Forward string                 `json:"forward"`
	Status  string                 `json:"status"`
	Type    string                 `json:"type"`
}

Message ...

func NewMessage added in v0.0.9

func NewMessage(b []byte) (message Message, err error)

NewMessage ...

func (*Message) Error added in v0.0.9

func (m *Message) Error(err error) *Message

Error ...

func (*Message) IsError added in v0.0.15

func (m *Message) IsError() (err error)

IsError ...

func (*Message) Pack added in v0.0.9

func (m *Message) Pack() []byte

Pack ...

func (*Message) Response added in v0.0.9

func (m *Message) Response(payload map[string]interface{}) *Message

Response ...

func (*Message) Success added in v0.0.9

func (m *Message) Success() *Message

Success ...

type StreamService

type StreamService struct {
	Hub *Hub
}

StreamService ...

func NewStreamService

func NewStreamService(hub *Hub) *StreamService

NewStreamService ...

func (*StreamService) Broadcast

func (s *StreamService) Broadcast(message []byte)

Broadcast ...

func (*StreamService) Subscribe

func (s *StreamService) Subscribe(command string, f func(client IStreamClient, msg Message))

Subscribe ...

func (*StreamService) UnSubscribe

func (s *StreamService) UnSubscribe(command string)

UnSubscribe ...

func (*StreamService) Ws

func (w *StreamService) Ws(ctx *gin.Context)

Ws ...

Jump to

Keyboard shortcuts

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