Coder Social home page Coder Social logo

rustychat's Introduction

RustyChat

Chat client made using Rust, Cursive, and PubNub. rustychat gif

What is RustyChat?

RustyChat is a realtime chat using the Rust language, Cursive as a Terminal UI, and the PubNub REST API to send and receive messages. I used a separate thread to run a subscribe loop that long polls PubNub for new messages. It will try to receive messages using a time token until the request times out or we get a message. The next request either has an updated time token if we got a response back or will redo that same request if we timed out. The main thread handles creating our UI using Cursive. It sends the channel name to the subscribe thread, and then shows the channel UI. When the user sends a message, we publish the new message to the channel we're in and also checks for more information to be sent to the UI.

Here is a diagram of how the app works! rustychat diagram

What is PubNub?

PubNub is a Realtime Data Streaming Network, essentially a Pub/Sub provider. They provide over 75 SDKs in addoition to their HTTP REST API. They have a huge free trial that allows users to send up to a million messages a month for free.

Sign up for PubNub click here:

Why RustyChat?

I wanted to create a Pub/Sub project in Rust and I think a multi user chat is a great demonstration of Pub/Sub. The concepts behind this project can be used towards any use case where one would want to publish and subscribe to channels. I soon want to integrate this into a Web Assembly application. ``

Installation

Sign up for PubNub to obtain API keys

PubNub Signup
  • Replace "INSERT_PUB_KEY_HERE" and "INSERT_SUB_KEY_HERE" with your PubNub keys

  • Use curl https://sh.rustup.rs -sSf | sh inside your command line interface to install Rust using rustup

  • Next run cargo run while inside of the folder containing cargo.toml

Your CLI should show packages being installed then the Cursive TUI should pop up asking for a username and channel name.

Open up two or more CLIs to simulate multiple users chatting in one channel!

Contributors

Samba Diallo

Special thank you to Jay Oster for both explaining and contributing!

rustychat's People

Stargazers

squerez 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.