In this lesson, we'll be using the three ships we created at the end of the first lesson. If you skipped the exercise, now is a good time to create those comets. If you need a refresher, here is the link back to those instructions.
The goal of this lesson is to explore the connected nature of Urbit. Unlike most computers we use, which imagined people using them by themselves, Urbit expects connection with other computers in a peer-to-peer mesh. We'll connect your three comets so you can send messages between them.
Getting a Comet's ID
To connect our comets, we'll need to know their ID. There's a catch, though. Star have a very short address — easy to remember and easy to type (e.g. ~paldev). Comets have a very long address — hard to remember, medium-hard to type.
Comet ids are in the form of four words separated by a dash, a double dash, and another four words separated by a dash.
Each word is six letters long made up of 2 3-letter syllables.
The syllables are easy to pronounce, but not meaningful.
For example
~daplyd-sonrem-hocfyr-difler--sopdut-poslec-sontyr-marzod
.
With long, hard to remember information, copy and paste is our go-to, and we will need a temporary place to store the ids we're copying. Any kind of document for writing will do.
Which leads to the second catch: finding the comet's id requires using the terminal. The Terminal app in Landscape can receive pasted information, but does not allow selecting or copying. To get around this, we'll use the "troubleshooting terminal" which allows selecting and coping.
To get to the troubleshooting terminal, go back to Home and select "Manage" beside the first comet.
Select the button from the middle panel labelled "Start in Terminal". This will shut down the comet and re-start it with a terminal window interface.
There will be a lot of messages. These messages are analogous to a living organism's heart beating, breath going in and out, the blood pumping, neurons firing, etc. All this traffic is Urbit taking care of itself and connecting with others.
To get the ship's id, we're going to use the command our
.
our
produces the ship's id which gets copied and pasted into a document.
Here is what mine looked like:
one: ~noddep-podmep-rontud-parmyl--lopbet-fantev-dinseg-samzod
two: ~dacmex-risryd-tanpec-ronmes--bidbyn-midpel-tasfun-litzod
three: ~daplyd-sonrem-hocfyr-difler--sopdut-poslec-sontyr-marzod
Sending Messages
Once we have our addresses, let's fire up a comet and head to Landscape. When you close the troubleshooting Terminal window, the ship will shut down, so use the "Boot" button to start it back up.
My com-one comet is already running, so I just need to click "Open". If you need to choose boot, it may take a bit longer.
Once in Landscape, open Terminal.
We're going to use the command |hi
, which deliberately has a pipe in front of it.
The |hi
command has three parts,
the command,
a target id, and
a message in quotes.
Here's an example:
> |hi ~noddep-podmep-rontud-parmyl--lopbet-fantev-dinseg-samzod "Hello, there!"
The result for the sender will be something like
>=
hi ~noddep-podmep-rontud-parmyl--lopbet-fantev-dinseg-samzod successful
The receiver will get a message with two parts, the id of the sender and the message.
< ~daplyd-sonrem-hocfyr-difler--sopdut-poslec-sontyr-marzod: Hello, there!
Make a Pal
Pasting (or worse typing) a long comet id for every message is too much work, so let's assign a variable to make life easier.
To do that, type =
followed by the short name of the variable.
Follow that with a space and then the information to assign to the variable (i.e. the id).
In my first comet I'll add
> =two ~dacmex-risryd-tanpec-ronmes--bidbyn-midpel-tasfun-litzod
And in my second comet I'll add.
> =one ~noddep-podmep-rontud-parmyl--lopbet-fantev-dinseg-samzod
Now I have a simple connection between the two ships. The conversation between them looks like this:
> =two ~dacmex-risryd-tanpec-ronmes--bidbyn-midpel-tasfun-litzod
> |hi two "Are you there?"
>=
hi ~dacmex-risryd-tanpec-ronmes--bidbyn-midpel-tasfun-litzod successful
< ~dacmex-risryd-tanpec-ronmes--bidbyn-midpel-tasfun-litzod: Yes! I am.
~noddep_samzod:dojo>
And on the other ship…
> =one ~noddep-podmep-rontud-parmyl--lopbet-fantev-dinseg-samzod
< ~noddep-podmep-rontud-parmyl--lopbet-fantev-dinseg-samzod: Are you there?
> |hi one "Yes! I am."
>=
hi ~noddep-podmep-rontud-parmyl--lopbet-fantev-dinseg-samzod successful
~dacmex_litzod:dojo>
This process works whether the computers are across the room or across the planet. Urbit IDs are unique addresses that allow you to find any online ship, connect to it, and communicate with it.
Exercise
Try to connect your third comet and send messages between all three.
Troubleshooting (What could possibly go wrong?)
If messages don't go through, make sure that you've included the ~
in the user id.
It really is important.
Next Up
A drawback with this method of messaging is that the receiver must have their Terminal open in order to receive the message. While no self-respecting hacker would close their Terminal window, most users never open theirs!
Another disadvantage is that we can only send messages to one person at a time--no group chats.
If all of this work in the Terminal feels very 1960s, don't worry, in our next lesson we'll move into a GUI (graphical user interface) world where things will feel more familiar. Hang on to those IDs, though. They'll come in very handy next lesson where we'll download our first app and make pals much more productively.