All Projects → alexandrevicenzi → go-sse

alexandrevicenzi / go-sse

Licence: MIT License
Server-Sent Events for Go

Programming Languages

go
31211 projects - #10 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to go-sse

Swell
Swell: API development tool that enables developers to test endpoints served over streaming technologies including Server-Sent Events (SSE), WebSockets, HTTP2, GraphQL, and gRPC.
Stars: ✭ 517 (+387.74%)
Mutual labels:  sse, server-sent-events
Demo Spring Sse
'Server-Sent Events (SSE) in Spring 5 with Web MVC and Web Flux' article and source code.
Stars: ✭ 102 (-3.77%)
Mutual labels:  sse, server-sent-events
Eventsource
EventSource client for Node.js and Browser (polyfill)
Stars: ✭ 541 (+410.38%)
Mutual labels:  sse, server-sent-events
Demo.AspNetCore.ServerSentEvents
Demo project for demonstrating functionality of Lib.AspNetCore.ServerSentEvents
Stars: ✭ 52 (-50.94%)
Mutual labels:  sse, server-sent-events
go-sse
Fully featured, spec-compliant HTML5 server-sent events library
Stars: ✭ 165 (+55.66%)
Mutual labels:  sse, server-sent-events
Sapphiredb
SapphireDb Server, a self-hosted, easy to use realtime database for Asp.Net Core and EF Core
Stars: ✭ 326 (+207.55%)
Mutual labels:  sse, server-sent-events
Axway Amplify Streams Js
AMPLIFY Streams Javascript package containing SDK, documentation and sample applications
Stars: ✭ 79 (-25.47%)
Mutual labels:  sse, server-sent-events
Golang Sse Todo
golang server sent events (sse) example
Stars: ✭ 23 (-78.3%)
Mutual labels:  sse, server-sent-events
Php Sse
A simple and efficient library implemented HTML5's server-sent events by PHP, is used to real-time push events from server to client, and easier than Websocket, instead of AJAX request.
Stars: ✭ 237 (+123.58%)
Mutual labels:  sse, server-sent-events
Server Push Hooks
🔥 React hooks for Socket.io, SEE, WebSockets and more to come
Stars: ✭ 176 (+66.04%)
Mutual labels:  sse, server-sent-events
http-event-stream
📡 Modern spec-compliant Server Sent Events stream implementation.
Stars: ✭ 16 (-84.91%)
Mutual labels:  sse, server-sent-events
go-gin-web-server
Deploy Go Gin on Render
Stars: ✭ 23 (-78.3%)
Mutual labels:  sse, server-sent-events
sseclient
Pure-Python Server Side Events (SSE) client
Stars: ✭ 85 (-19.81%)
Mutual labels:  sse, server-sent-events
sse
HTML5 Server-Sent-Events for Go
Stars: ✭ 84 (-20.75%)
Mutual labels:  sse, server-sent-events
Lib.aspnetcore.serversentevents
Lib.AspNetCore.ServerSentEvents is a library which provides Server-Sent Events (SSE) support for ASP.NET Core
Stars: ✭ 138 (+30.19%)
Mutual labels:  sse, server-sent-events
react-native-sse
Event Source implementation for React Native. Server-Sent Events (SSE) for iOS and Android 🚀
Stars: ✭ 51 (-51.89%)
Mutual labels:  sse, event-source
geo-smart-system
Open Source Realtime Tracking System
Stars: ✭ 36 (-66.04%)
Mutual labels:  sse, server-sent-events
ruby-eventsource
Server-sent events (SSE) client implementation for Ruby
Stars: ✭ 19 (-82.08%)
Mutual labels:  server-sent-events
FFmpegPlayer
Simple FFmpeg video player
Stars: ✭ 72 (-32.08%)
Mutual labels:  sse
cs
开箱即用的基于命令的消息处理框架,让 websocket 和 tcp 开发就像 http 那样简单
Stars: ✭ 19 (-82.08%)
Mutual labels:  sse

go-sse

Go Report Card Build Status GoDoc

Server-Sent Events for Go

About

Server-sent events is a method of continuously sending data from a server to the browser, rather than repeatedly requesting it, replacing the "long polling way".

It's supported by all major browsers and for IE/Edge you can use a polyfill.

go-sse is a small library to create a Server-Sent Events server in Go and works with Go 1.9+.

Features

  • Multiple channels (isolated)
  • Broadcast message to all channels
  • Custom headers (useful for CORS)
  • Last-Event-ID support (resend lost messages)
  • Follow SSE specification
  • Compatible with multiple Go frameworks

Instalation

go get github.com/alexandrevicenzi/go-sse

Example

Server side:

package main

import (
    "log"
    "net/http"
    "strconv"
    "time"

    "github.com/alexandrevicenzi/go-sse"
)

func main() {
    // Create SSE server
    s := sse.NewServer(nil)
    defer s.Shutdown()

    // Configure the route
    http.Handle("/events/", s)

    // Send messages every 5 seconds
    go func() {
        for {
            s.SendMessage("/events/my-channel", sse.SimpleMessage(time.Now().Format("2006/02/01/ 15:04:05")))
            time.Sleep(5 * time.Second)
        }
    }()

    log.Println("Listening at :3000")
    http.ListenAndServe(":3000", nil)
}

Client side (JavaScript):

e = new EventSource('/events/my-channel');
e.onmessage = function(event) {
    console.log(event.data);
};

More examples available here.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].