Ping status

By Daveoh on Apr 10, 2010

This is a simple script which displays your ping (in milliseconds) to the server via a custom window.
After loading the script and connecting to a server, the script will set a timer to ping all connected servers every 60 seconds. This will be displayed in the custom window list.

on *:CONNECT:{
  if (!$timer(pingservers)) { timerpingservers 0 60 scon -at1 pingservers }
  if (!$window($+(@,$cid,.Ping:*),1)) { window -nk0 @ $+ $cid $+ .Ping: - }
}

alias pingservers {
  if ($($+(%,pingResp,$cid),2)) {
    renwin $window($+(@,$cid,.Ping:*),1) @ $+ $cid $+ .Ping: >60000
    echo -t $window($+(@,$cid,.Ping:*),1) >60000
  }
  set %pingResp $+ $cid 1
  .raw PING : $+ $ticks
}

on ^*:PONG:{
  var %ticks = $ticks
  if ($($+(%,pingResp,$cid),2)) {
    var %ping = $calc(%ticks - $($+($,$0),2))
    if (!$window($+(@,$cid,.Ping:*),1)) { window -nk0 @ $+ $cid $+ .Ping:  $+ %ping }
    else { renwin $window($+(@,$cid,.Ping:*),1) @ $+ $cid $+ .Ping:  $+ %ping }
    echo -t $window($+(@,$cid,.Ping:*),1) %ping
    unset %pingResp $+ $cid
    haltdef
  }
}

Comments

Sign in to comment.
Daveoh   -  Apr 17, 2010

Those numbers are how many milliseconds it took. I.e. 1000 = 1 second. A good ping is below 100 ms.

 Respond  
Celeron   -  Apr 16, 2010

;::::: window @27.ping.516
[09:46] 21141
[09:47] 516
;:::::

..
how i can know how much my ping result?
"displays your ping (in milliseconds)"

 Respond  
Daveoh   -  Apr 10, 2010

I think a single line in a treebar is pretty small, smaller than a tip, and less obstructive... Won't work very well in a switchbar however.

 Respond  
sunslayer   -  Apr 10, 2010

instead of creating a new window you should look into using the $tip identifier, or a smaller window

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.