Skip to content

Releases: thomas-osgood/ssehandler

v1.2.0

Choose a tag to compare

@thomas-osgood thomas-osgood released this 25 Sep 23:41
f385a76

What's Changed

Full Changelog: v1.1.0...v1.2.0

Added more CORS header options for SSEHandler.

v1.1.0

Choose a tag to compare

@thomas-osgood thomas-osgood released this 05 Sep 20:22
46155b9

What's Changed

Full Changelog: v1.0.2...v1.1.0

Optimizations.

  • Added mutex for synchronization safety.
  • Updated UUID generation logic.
  • Buffered comms channel.

v1.0.2

Choose a tag to compare

@thomas-osgood thomas-osgood released this 09 Jul 22:57
1f765f0

Overview

SSEChannelMap now uses the github.com/google/uuid library to generate UUID keys.

New:

type SSEChannelMap map[uuid.UUID]SSEChannel

Old:

type SSEChannelMap map[string]SSEChannel

Associated Issues

#5 : Use UUID

v1.0.1

Choose a tag to compare

@thomas-osgood thomas-osgood released this 06 Jul 18:53
30def67

Overview

Added a new ID field to the SSEMessage struct and added JSON and XML tags to the SSEMessage fields.

SSEMessage

type SSEMessage struct {
	// name of the event that will be transmitted.
	Event string `json:"event" xml:"event"`
	// id assigned to the event type. (optional)
	Id string `json:"id" xml:"id"`
	// data to be transmitted to the client.
	//
	// for best results, this should be a JSON object.
	Data string `json:"data" xml:"data"`
}

Associated Issues

#1 and #3

v1.0.0

Choose a tag to compare

@thomas-osgood thomas-osgood released this 05 Jul 23:09
2ff6cc5

Description

Initial release of the SSE Handler library.

This handler will add clients to the client map when they connect and remove them when they disconnect. This will automatically create a channel for each client that connects, allowing the function feeding the channels to focus on generating the information and now worry about the channel management.

Basic SSE functionality and endpoint function are included within this release.

// most likely a global variable ...
clientMap := make(ssehandler.SSEChannelMap)

// other code

hdl, err := ssehandler.NewSSEHandler(ssehandler.WithClientMap(clientMap))
if err != nil {
    // handle error
}

http.HandleFunc("/sse", hdl.EndpointFunc)

// other code
// in "worker function"

eventtype =  "message"

payload, err = json.Marshal(data)
if err != nil {
    // handle error
}

// this will transmit the data to all clients in the client map.
for _, curchan := range clientMap {
   curchan <- ssehandler.SSEMessage{Data: string(payload), Event: eventtype}
}