10 // implements APIReply
11 gob.RegisterName("*udpapi.UptimeReply", &UptimeReply{})
12 // implements APIReply
13 gob.RegisterName("*udpapi.PingReply", &PingReply{})
16 type UptimeReply struct {
21 // Retrieves the server's uptime. The recommended way to verify if a session
24 // Returns a channel through which the eventual response will be sent.
26 // http://wiki.anidb.net/w/UDP_API_Definition#UPTIME:_Retrieve_Server_Uptime
27 func (a *AniDBUDP) Uptime() <-chan *UptimeReply {
28 ch := make(chan *UptimeReply, 2)
30 reply := <-a.SendRecv("UPTIME", ParamMap{})
32 r := &UptimeReply{APIReply: reply}
34 uptime, _ := strconv.ParseInt(reply.Lines()[1], 10, 32)
35 r.Uptime = time.Duration(uptime) * time.Millisecond
43 type PingReply struct {
45 Port uint16 // This client's local UDP port
48 // Simple echo command. The recommended way to verify if the server
49 // is alive and responding. Does not require authentication.
51 // Returns a channel through which the eventual response will be sent.
53 // http://wiki.anidb.net/w/UDP_API_Definition#PING:_Ping_Command
54 func (a *AniDBUDP) Ping() <-chan *PingReply {
55 ch := make(chan *PingReply, 2)
57 reply := <-a.SendRecv("PING", ParamMap{"nat": 1})
59 r := &PingReply{APIReply: reply}
61 port, _ := strconv.ParseUint(reply.Lines()[1], 10, 16)