Преглед на файлове

Merge pull request #37 from iopred/updatestatus

Make update status a little more idiomatic.
Bruce преди 9 години
родител
ревизия
5c64020544
променени са 1 файла, в които са добавени 5 реда и са изтрити 12 реда
  1. 5 12
      wsapi.go

+ 5 - 12
wsapi.go

@@ -64,8 +64,8 @@ type updateStatusGame struct {
 }
 }
 
 
 type updateStatusData struct {
 type updateStatusData struct {
-	IdleSince json.Token  `json:"idle_since"`
-	Game      interface{} `json:"game"`
+	IdleSince *int              `json:"idle_since"`
+	Game      *updateStatusGame `json:"game"`
 }
 }
 
 
 type updateStatusOp struct {
 type updateStatusOp struct {
@@ -80,17 +80,10 @@ func (s *Session) UpdateStatus(idle int, game string) (err error) {
 
 
 	var usd updateStatusData
 	var usd updateStatusData
 	if idle > 0 {
 	if idle > 0 {
-		usd.IdleSince = idle
-	} else {
-		usd.IdleSince = nil
+		usd.IdleSince = &idle
 	}
 	}
-
-	var usg updateStatusGame
-	if game == "" {
-		usd.Game = nil
-	} else {
-		usg.Name = game
-		usd.Game = usg
+	if game != "" {
+		usd.Game = &updateStatusGame{game}
 	}
 	}
 
 
 	data := updateStatusOp{3, usd}
 	data := updateStatusOp{3, usd}