Giter Site home page Giter Site logo

nietaki / server_sent_event.ex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from crowdhailer/server_sent_event.ex

0.0 2.0 0.0 61 KB

Push updates to Web clients over HTTP or using dedicated server-push protocol

License: Apache License 2.0

Elixir 100.00%

server_sent_event.ex's Introduction

ServerSentEvent

Build Status

Push updates to web clients over HTTP, using dedicated server-push protocol.

Server Sent Event Standard

https://html.spec.whatwg.org/#server-sent-events

Usage

Parsing and Serializing

iex(1)> event = ServerSentEvent.new("my data")
%ServerSentEvent{
  comments: [],
  id: nil,
  lines: ["my data"],
  retry: nil,
  type: nil
}

iex(2)> binary = ServerSentEvent.serialize(event)
"data: my data\n\n"

iex(3)> {:ok, {^event, ""}} = ServerSentEvent.parse(binary)
{:ok,
 {%ServerSentEvent{
    comments: [],
    id: nil,
    lines: ["my data"],
    retry: nil,
    type: nil
  }, ""}}

Client

This project also includes a general purpose client. See documentation for ServerSentEvent.Client for more information.

Testing

git clone [email protected]:CrowdHailer/server_sent_event.ex.git
cd server_sent_event.ex

mix deps.get
mix test
mix dialyzer

server_sent_event.ex's People

Contributors

crowdhailer avatar nietaki avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.