sse

package module
v0.0.0-...-1b1c02d Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: MIT Imports: 5 Imported by: 0

README

sse

Middleware sse provides Server-Sent Events to channels binding for Macaron.

Installation
go get github.com/go-macaron/sockets
Usage

Have a look into the example directory to get a feeling for how to use the sse package.

This package essentially provides a binding of Server-Sent Event to channels, which you can use as in the following, contrived example:

m.Get("/stat", sse.Handler(stat{}), func(msg chan<- *stat) {
    for {
        select {
        case <-time.Tick(1 * time.Second):
            msg <- getStat()
        }
    }
})

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(bind interface{}, options ...*Options) macaron.Handler

Types

type Connection

type Connection struct {
	*Options

	// Sender is the channel used for sending out data to the client.
	// This channel gets mapped for the next handler to use with the right type
	// and is asynchronous unless the SendChannelBuffer is set to 0.
	Sender reflect.Value
	// contains filtered or unexported fields
}

type Options

type Options struct {
	// The time to wait between sending pings to the client
	PingInterval time.Duration
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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