mIRC Homepage
Posted By: Artfull_dodger JAVA (ping / highscan) - 03/03/03 01:29 PM
Hi,

I'm writting a little applet to connect to an IRC channel. My problem is that I don't know what a highscan command needs to return to the server, also I don't know how to calculate the ping time.

Thanks in advance
Pieter Pareit
Posted By: Online Re: JAVA (ping / highscan) - 03/03/03 06:11 PM
Ping is simple. When you type /ctcp <nick> ping, you actually send:
Code:

PRIVMSG nick :PING 1046714259

Where  equals to $chr(1), which identifies CTCP and /me messages, and 104671425 is the local $ctime value.

When the destination nick receives the Ping, it can decide whether to reply or ignore. In case it replies, it simply sends back the same message but by notice, instead of a privmsg.

Rule: ctcp request = privmsg; ctcp reply = notice.
Code:

NOTICE yournick :PING 1046714259

Now that you receive the reply, you'll have to substract the numeric parameter from the current $ctime, so that you can know how many seconds left since it was sent.

For more info check this page. As for highscan, sorry no idea.
Posted By: Hammer Re: JAVA (ping / highscan) - 03/03/03 09:03 PM
I think he meant the raw PING from the server (Ping? Pong!) to keep the connection alive.

All you need to do is return the parameter.
on *:PING: .raw PONG $1
Posted By: Online Re: JAVA (ping / highscan) - 03/03/03 09:11 PM
I also thought he's talking about server pings, but he wrote "calculation" in his post, that usually refers to client-to-client ping.
Posted By: Artfull_dodger Re: JAVA (ping / highscan) - 04/03/03 02:20 PM
No no, it is the time to reach another person. When you right click on a nick name you can ask the version/time and ping. The ping returns in interval in seconds. But the seconds are return like 123025654 and I don't know how to calculate these in for example 3 sec
Posted By: Hammer Re: JAVA (ping / highscan) - 04/03/03 07:31 PM
Then Online was correct. smile

When you CTCP Ping someone, you send them a PRIVMSG nickname : $+ $chr(1) $+ PING $ctime $+ $chr(1) .. the server delivers the message to them and their client will return your $ctime value to you. What you do when you receive it is to subtract that returned value from your current $ctime, giving you a $duration in seconds of the amount of time it took for the round trip. Most scripts do not divide the duration value by 2 to get the one-way duration.

$ctime is the number of seconds since epoch (1970 January 1 00:00:00 GMT). That's 33 years 2 months 3 days 14 hours 30 minutes 07 seconds ago, currently.

on *:CTCPREPLY:PING*: echo $color(notice) -abfirt * Ping reply for $nick $+ : $duration($calc($ctime - $2)) | halt
© mIRC Discussion Forums