chat over gemini (or, let's play with streaming text)

Omar Polo op at omarpolo.com
Tue Oct 5 16:15:10 BST 2021
Chris McGee <newton688@gmail.com> writes:

> I feel that using Gemini for things where other established protocols are better designed for the task is a path to it becoming just
> another web protocol that tries to do everything, poorly. A much better model might be something like Unix where you have tools
> that do their thing well and also work together well.

I agree with that, there are surely better way to chat!

I was mostly trying to get some fun with the streaming ability of
text/gemini, and the chat was the first thing I could think of, and also
the easiest to implement (it's crap written in less than 50 lines of
shell, including blanks.)  It's more of a demonstration of how easy and
useful streaming pages can be.

Thinking of text/gemini as a (possibly) "infinite" stream of lines is an
interesting perks of gemini, and can unlock the creation of simple, yet
very powerful applications.  Think of a fediverse instance over gemini,
or maybe station, with a "feed" page that streams toots/posts.  Or a
news site that streams live events.

Now, not every capsule needs to stream pages of course, but I was mostly
trying to bring up the point again, and see if it stimulates someone
to create something more useful. ;-)

> Having said that, I wonder if Gemtext would be a decent marking down content in a chat system, such as IRC, or in a great many
> other places in a Gemini fediverse. Line orientation could be a nice feature there.
>
> On Mon, Oct 4, 2021 at 2:45 PM Omar Polo <op@omarpolo.com> wrote:
>
>  Hello,
>
>  One of the things that I love about text/gemini is how it's easy to
>  parse, and being it line-based it's also really easy to stream it.  When
>  I started working on telescope, the idea of being able to stream content
>  was present in the design of the parser from the first draft -- it also
>  fit nicely with separation in multiple processes (one process does the
>  fetching, another one the rendering, and messages are sent from one proc
>  to the other.)  But other than knowing from the code that it should
>  work, I never played with this aspect of text/gemini.
>
>  Fast forward various months, I've just watched the "Why gemini" video by
>  Tomasino and I got an urge to build something with streaming text.  I'm
>  attaching a very, very simple CGI script that streams text/gemini to
>  build an interactive chatroom.
>
>  The idea is similar to the one presented by solderpunk in "A vision for
>  gemini applications"
>
>  gemini://gemini.circumlunar.space/users/solderpunk/gemlog/a-vision-for-gemini-applications.gmi
>
>  and, frankly, I'm quite disappointed nobody has built something like
>  this before.  (or at least I haven't been able to find it.  I know
>  kensanata has made some experiments with a mush, but I haven't played
>  with it (yet))
>
>  The idea is to provide two pages: one that accepts input via the
>  response code 10 and appends to a file, the second is a literal `tail
>  -f'.  Simple, but it works, and it's immediate.  As soon as someone
>  sends something, all the clients reading from `tail -f' gets the
>  message.
>
>  (the various `tail -f' gets eventually killed by a SIGPIPE when the
>  client closes the connection and the server closes the script stdout.
>  It could take a while due to the buffering, but can be worked out.  I
>  don't know if servers are expected to kill the spawned scripts -- I
>  don't recall anything from the RFC -- but I'm probably wrong.  gmid
>  anyway doesn't kill the scripts, it let UNIX do its things with signals.
>  Feature or bug?  dunno.)
>
>  It doesn't require a client certificates, but uses the subject of it if
>  provided.  There's a check that can be de-commented to enforce the usage
>  of client certificates.
>
>  I'm hosting a demo at
>
>          gemini://gemini.omarpolo.com/cgi/lets-chat
>
>  but I don't promise to keep it online.  It's a quick-n-dirty script
>  (less than 50 lines of -hopefully- portable sh), probably filled with
>  bugs, wrote only to be a demonstration.  I don't want to moderate it
>  if/when people write things.  It's really easy to host it locally, for
>  e.g. using gmid (disclaimer: I'm the author)
>
>          $ gmid -x '*' .
>
>  from the same directory where you saved the script.
>
>  It seems to work with Telescope, Tinmop and Lagrange.  Kristall and
>  Amfora don't seem to support streaming, or maybe I have an old version.
>  Elpher doesn't stream by design.
>
>  I hope this inspires someone to build amazing things with the streaming
>  capability of text/gemini.  There are a lot of possibilities, for
>  instance capsules like station could stream the feed, or the
>  notification page; it could be better than clients continously
>  refreshing the page.  Think of it like some sort of "websockets" but for
>  humans ;)
>
>  Gemini clients could "ring" or use some other kind of mechanism to
>  inform the user that more content is available in a page (for
>  e.g. Telescope adds a `!'  before the tab title.)
>
>  Cheers,
>
>  Omar Polo
>
>  P.S.: this is also a partial reply to the talkat spec.  I love seeing
>  what creative things folks are building, and I really hope the best for
>  mbays and their idea (if I got the paternity correctly :P), but I also
>  like the idea of doing these sort of things over gemini.  On one hand I
>  don't want to push gemini over its boundaries, on the other I love doing
>  that :)



Archive home | About this archive