Skip to content
/ Ditto Public

Pure Erlang IRC Client, a project to learn erlang and wxerlang

Notifications You must be signed in to change notification settings

alep/Ditto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Ditto

A pure Erlang IRC client

I started this project to learn Erlang. It started as a IRC robot, but turned into a client the moment I wanted to add a GUI and learn wxErlang.

When I started with the robot, the idea was to hide the IRC protocol using one of the Erlang behaviours. I found that the most suitable was the gen_event behaviour, mostly because of the eventful nature of the IRC protocol.

Although I did try using gen_fsm and gen_server, but it seemed, that these behaviours didn't fit, at least from my point of view.

The idea of hiding the IRC protocol behing a gen_event behaviour remains. Although lately I'm thinking it might not be a good idea or it's wasteful.

The following (ascii)-diagram shows, what's yet to be implemented, how would I hide using gen_event an error msg from the server when trying to subscribe a nick.

+----------+                +----------+        gen_event:         +----------+
|          |   NICK anick   |          |  notify({nick, "anick"})  | wxErlang |
|IRC Server|  <-----------  |gen_event |  <----------------------  |   GUI    |
|          |                |          |                           |          |
+----------+                +----------+                           +----------+

                                  |
                                  | State = "sent nick"
                                  |
                                 \ /
                                  '

+----------+                   +----------+                       +----------+
|          | ERR_NICKNAMEINUSE |          |                       | wxErlang |
|IRC Server| ----------------> |gen_event |                       |   GUI    |
|          |                   |          |                       |          |
+----------+                   +----------+                       +----------+

                                  |
                                  | State = "sent pass"
                                  | (or whatever before nick)
                                 \ /
                                  '
                                           (need some sort of
+----------+                 +----------+   callback into the GUI)  +----------+
|          |                 |          |   UIPid ! { badnick }     | wxErlang |
|IRC Server|                 |gen_event |   --------------------->  |   GUI    |
|          |                 |          |                           |          |
+----------+                 +----------+                           +----------+

I think it is wasteful because I don't think I need gen_event to hide all this, I could just use the process that controls the socket which talks to gen_event. It might make things simpler.

Anyway I'm looking for comments on the idea and the code.

Thanks.

How to use

$ erl
Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.5  (abort with ^G)
1> c(conn).
{ok,conn}
2> c(ircmsg).
{ok,ircmsg}
3> c(ircclient).
{ok,ircclient}
4> c(dittoui).
{ok,dittoui}
5> dittoui:start().
<0.61.0>
Next File -> Connect,
with "chat.freenode.net", 6667, <somenick>, <someusername>

Thanks, again.

About

Pure Erlang IRC Client, a project to learn erlang and wxerlang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages