2008-02-08 15:38:31 -07:00
|
|
|
open Unixqueue
|
|
|
|
|
2008-02-14 18:53:57 -07:00
|
|
|
class ircd_connection
|
|
|
|
(ues : unix_event_system)
|
|
|
|
?(output_timeout = -.1.0)
|
|
|
|
?(ibuf_max = 4096)
|
|
|
|
?(max_outq = 50)
|
|
|
|
?(max_unsent = 4096)
|
|
|
|
fd =
|
2008-02-08 15:38:31 -07:00
|
|
|
object (self)
|
2008-02-14 18:53:57 -07:00
|
|
|
inherit Connection.buffered_connection
|
|
|
|
ues
|
|
|
|
~output_timeout
|
|
|
|
~ibuf_max
|
|
|
|
~max_outq
|
|
|
|
~max_unsent
|
|
|
|
fd
|
2008-02-08 18:11:49 -07:00
|
|
|
|
|
|
|
method handle_line line =
|
|
|
|
let parts = Pcre.split ~pat:" " line in
|
|
|
|
match parts with
|
|
|
|
| ["NICK"; nick] ->
|
|
|
|
self#log ("Set nickname to " ^ nick);
|
2008-02-14 18:53:57 -07:00
|
|
|
self#write [":testserver.test"; "NOTICE"; nick; ":*** Hi there."];
|
|
|
|
self#write ["PING"; ":12345"];
|
2008-02-08 18:11:49 -07:00
|
|
|
| _ ->
|
|
|
|
self#log ("Unknown: " ^ line)
|
|
|
|
|
2008-02-14 18:53:57 -07:00
|
|
|
method die reason =
|
|
|
|
self#log ("Dying: " ^ reason)
|
2008-02-08 15:38:31 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
let main () =
|
|
|
|
let ues = new unix_event_system () in
|
|
|
|
let handle_connection fd =
|
|
|
|
prerr_endline "hi!";
|
|
|
|
let c = new ircd_connection ues fd in
|
|
|
|
c#debug true
|
|
|
|
in
|
|
|
|
Connection.establish_server
|
|
|
|
ues
|
|
|
|
handle_connection
|
|
|
|
(Unix.ADDR_INET (Unix.inet_addr_any, 7777));
|
|
|
|
ues#run ()
|
|
|
|
|