Skip to content

A simple chat application to understand Elixir's OTP Distribution functionality. This is a simple supervisor application that leverages distributed tasks to allows users to chat with one another via an iex session, across distributed nodes.

Notifications You must be signed in to change notification settings

kalpak92/Simple-Chat-Application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Distributed Tasks - Simple Chat Application

The Chat application is pretty simple. It sends messages to remote nodes and remote nodes respond to those messages by IO.puts-ing them out to the STDOUT of the remote node.

Usage

In one terminal window, start up our chat app in a named iex session

iex --sname alex@localhost -S mix

Open up another terminal window to start the app on a different named node:

iex --sname kate@localhost -S mix

Now, from the alex node, we can send a message to the kate node:

iex(alex@localhost)> Chat.send_message(:kate@localhost, "hi")
:ok

Switch to the kate window and you should see the message:

iex(kate@localhost)> hi

The kate node can respond back to the alex node:

iex(kate@localhost)> hi
Chat.send_message(:alex@localhost, "how are you?")
:ok
iex(kate@localhost)>

And it will show up in the alex node’s iex session:

iex(alex@localhost)> how are you?

Let's have another node named moebi

iex --sname moebi@localhost -S mix

Let’s have alex send a message to moebi:

iex(alex@localhost)> Chat.send_message(:moebi@localhost, "hi")
chicken?
:ok

We can see that the alex node received the response, "chicken?". If we open the kate node, we’ll see that no message was received, since neither alex nor moebi send her one (sorry kate). And if we open the moebi node’s terminal window, we’ll see the message that the alex node sent:

iex(moebi@localhost)> hi

About

A simple chat application to understand Elixir's OTP Distribution functionality. This is a simple supervisor application that leverages distributed tasks to allows users to chat with one another via an iex session, across distributed nodes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages