August 2025
Intermediate to advanced
272 pages
6h 14m
English
In this chapter, we won’t dive too deep into building reliable, scalable TCP clients. Instead, we’ll write a simple terminal-based interface for our chat server, just to see it working in real time. To reuse our protocol code (in Chat.Protocol), we’ll build the client right inside the chat project we worked on throughout this chapter. It’ll be somewhat of a hack, but we’ll write our client as a Mix task. Hop into a new file and let’s get started.
| | defmodule Mix.Tasks.ChatClient do |
| | use Mix.Task |
| | |
| | import Chat.Protocol |
| | |
| | alias Chat.Message.{Broadcast, Register} |
| | |
| | end |
We’re starting out with a new Mix task, which by convention we place in the lib/mix/tasks directory. Mix tasks ...
Read now
Unlock full access