onyx-40-loc-distributed-chat

Version, currently master branch1 version
  • master branchlatestAug 13, 2019

github.com/vladfaust/onyx-40-loc-distributed-chat

A 40-LoC example of a distributed websocket chat build with [Onyx Framework](https://onyxframework.org). Read the blogpost at https://blog.onyxframework.org/posts/distributed-websocket-chat-in-40-loc

2 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  onyx-40-loc-distributed-chat:
    github: vladfaust/onyx-40-loc-distributed-chat
    branch: master

master is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
0.30.1
License
MIT
Author
Vlad Faust
Target
  • server from src/server.cr

Dependencies

Runtime Dependencies

  • onyx~> 0.6.0github: onyxframework/onyx
  • onyx-eda~> 0.4.0github: onyxframework/eda
  • onyx-http~> 0.9.0github: onyxframework/http

README

Built with Crystal Travis CI build

This repository contains code from the Distributed websocket chat in 40 lines of code blog post. It is powered by Crystal, Onyx Framework and Redis.

⚠️ NOTE: The application requires Redis version >= 5!

Installation

  1. Install Crystal. See the installation instructions.

  2. Clone the repository:

> git clone https://github.com/vladfaust/onyx-40-loc-distributed-chat && \
cd onyx-40-loc-distributed-chat
  1. Install dependenies:
> shards install
  1. Run the server:
> env REDIS_URL=<YOUR_REDIS_5_URL> PORT=5000 crystal src/server.cr
  1. Test the server with wscat:
> wscat --connect localhost:5000?username=Alice
> Hi
< Alice: Hi
>
  1. Repeat steps 3 and 4 with another PORT to see the distribution in action.

Contributors

Licensing

This software is licensed under MIT License.

Open Source Initiative