sse: github.com/lonord/sse Index | Files

package sse

import "github.com/lonord/sse"

Index

Package Files

config.go sse.go util.go

func GenerateClientID Uses

func GenerateClientID() string

GenerateClientID is used to generate an uuid randomly

type CloseType Uses

type CloseType int

CloseType present the type of closing

const (

    // ClientClose present client initiative to disconnect
    ClientClose CloseType
    // ServerClose present server initiative to disconnect
    ServerClose
)

type Event Uses

type Event struct {
    Event string
    ID    string
    Retry uint
    Data  interface{}
}

Event is the Server-Sent Event data struct

type Option Uses

type Option struct {
    Headers map[string]string
}

Option is used for initialize sse service

type Service Uses

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

Service is the type of sse service instance

func NewService Uses

func NewService() *Service

NewService is used to create a sse.Service instance

func NewServiceWithOption Uses

func NewServiceWithOption(o Option) *Service

NewServiceWithOption is used to create a sse.Service instance with additional option

func (*Service) Broadcast Uses

func (s *Service) Broadcast(e Event)

Broadcast is used to broadcast event to all connected clients

func (*Service) CloseAllClients Uses

func (s *Service) CloseAllClients()

CloseAllClients is used to disconnect all clients

func (*Service) CloseClient Uses

func (s *Service) CloseClient(clientID interface{}) error

CloseClient is used to disconnect client by server

func (*Service) GetClientCount Uses

func (s *Service) GetClientCount() int

GetClientCount is used to get count of client

func (*Service) HandleClient Uses

func (s *Service) HandleClient(clientID interface{}, w http.ResponseWriter) (<-chan CloseType, error)

HandleClient is used to handle a client with streaming and returns a chan of closing

func (*Service) Send Uses

func (s *Service) Send(clientID interface{}, e Event) error

Send is used to send data to client

Package sse imports 9 packages (graph). Updated 2018-10-16. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).