respond to client PING messages
This commit is contained in:
parent
7de285524a
commit
8348f2dc1f
|
@ -541,6 +541,21 @@ let on_msg_motd t =
|
|||
motd t;
|
||||
Ok ()
|
||||
|
||||
let on_msg_ping t token =
|
||||
let* _me = require_registered t in
|
||||
match token with
|
||||
| None -> Ok ()
|
||||
| Some token ->
|
||||
let prefix = Server_info.prefix t.server_info in
|
||||
Outbox.send t.outbox
|
||||
(Msg.make ~prefix "PONG" [t.server_info.hostname; token]
|
||||
~always_trailing:true);
|
||||
Ok ()
|
||||
|
||||
let on_msg_pong t _token =
|
||||
let* _me = require_registered t in
|
||||
Ok ()
|
||||
|
||||
let welcome t me =
|
||||
let whoami = Msg.prefix_string (User.prefix me) in
|
||||
let s_hostname = t.server_info.hostname in
|
||||
|
@ -655,6 +670,8 @@ let dispatch t = function
|
|||
| "USER", unm :: _ :: _ :: rnm :: _ -> on_msg_user t unm rnm
|
||||
| "QUIT", reason -> on_msg_quit t (concat_args reason)
|
||||
| "MOTD", _ -> on_msg_motd t
|
||||
| "PING", args -> on_msg_ping t (concat_args args)
|
||||
| "PONG", args -> on_msg_pong t (concat_args args)
|
||||
| "PRIVMSG", ([] | "" :: _) -> Error norecipient
|
||||
| "PRIVMSG", ([_] | _ :: "" :: _) -> Error notexttosend
|
||||
| "PRIVMSG", tgt :: msg :: _ -> on_msg_privmsg t tgt msg
|
||||
|
|
Loading…
Reference in New Issue