Giter VIP home page Giter VIP logo

ditto's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.