mgold/elm-socketio 2.0.4

Socket.io (websockets) for bidirectional realtime messaging

Platform: Elm

Language: Elm

License: BSD-3-Clause

Repository: https://github.com/mgold/elm-socketio

View on registry: http://package.elm-lang.org/packages/mgold/elm-socketio/2.0.4

Direct download link: https://github.com/mgold/elm-socketio/archive/2.0.4.zip

Install: elm-package install mgold/elm-socketio 2.0.4


Socket.io for Elm

This library provides Elm code with realtime push-based two-way communication with a server using socket.io. It works quite well for the most common use case, a stable connection to a server that you wrote in Node.js.

That said, error handling is limited to setting options up front and reading the connection status. Joining rooms, an inherently impure action, is not supported. If you need to dynamically connect and disconnect, or interface with an API you don't control, use JavaScript.

Note that vanilla websockets (i.e. servers other than Socket.io) are not supported. You should use ports and the JS Websocket API.

For documentation, see src/SocketIO.elm. Supports Elm 0.16 and Socket.io 1.4.4. If this version is causing problems, open an issue to bump to the latest version.

Examples

For each example, a working Elm client and Node server are provided. You will need to cd examples to start. This first time you do this, you will also need to npm install to get socket.io for the server. Then in separate terminals, run node <example-name>/server.js and elm reactor, then open your browser and navigate to the example as you normally would with the reactor.

Numbers

In this example, client and server exchange a number, incrementing it each time. The server sees odd numbers and the client sees even numbers.

This example is big enough to show all the useful features of the library, but no bigger. There is also a version using The Elm Architecture and elm-effects (with the same server).

Chat

The main example: a realtime chat program. You can test it out yourself with multiple browser tabs.

Chat is divided into five modules. Protocol most of the knowledge shared with the server and a few other common functions. Login is the login page, Post is the text field and submit button, and View makes the messages look pretty. Finally, ChatClient pulls it all together and does the I/O.

Connected

A very simple example to show that you can obtain a signal about the connection state and use this to render information in the UI.

Releases

  • 2.0.4 - April 22, 2016 21:52
  • 2.0.3 - January 20, 2016 17:01
  • 2.0.2 - December 20, 2015 17:00
  • 2.0.1 - November 19, 2015 17:01
  • 2.0.0 - July 01, 2015 17:01
  • 1.0.2 - June 29, 2015 17:00
  • 1.0.1 - June 06, 2015 17:00
  • 1.0.0 - June 02, 2015 17:00

Project Statistics

SourceRank 10
Dependencies 1
Dependent projects 0
Dependent repositories 8
Total releases 8
Latest release
First release
Stars 50
Forks 6
Watchers 3
Contributors 3
Repo Size: 2.38 MB

Top Contributors See all

Max Goldstein Dan Neumann Matthias Benkort

Something wrong with this page? Make a suggestion

Export .ABOUT file for this library

Last synced: 2016-11-15 09:52:43 UTC

Login to resync this project