Skip to content

rndz/sse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Go library for SSE (Server-Sent Events) client

GoDoc

Implementation of Server-Sent Events EventSource interface. Still work in progress - API might break!

Simple usage:

package main

import (
	"fmt"
	"log"
	"runtime"

	"github.com/rndz/sse"
)

func main() {
	cfg := &sse.Config{
		URL: "http://example.com/chat",
	}
	client, err := sse.New(cfg)
	if err != nil {
		log.Fatal(err)
	}
	client.AddListener("join", func(e sse.Event) {
		fmt.Printf("%s has joined the conversation\n", e.Data)
	})
	client.AddListener("leave", func(e sse.Event) {
		fmt.Printf("%s has left the conversation\n", e.Data)
	})
	client.AddListener("error", func(e sse.Event) {
		log.Printf("error in sse stream: %s", e.Data)
	})
	client.Connect()
	runtime.Goexit()
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages