Пример #1
0
// Test ServiceInfo JSON marshaling
func TestJsonServiceInfo(t *testing.T) {
	info := core.ServerInfo{
		Version:      "1.2.3",
		Timestamp:    "2015-10-22T14:15:16.999",
		WebsocketUrl: "ws://devicehive.com"}
	testCheckJson(t, info, `{"apiVersion":"1.2.3","serverTimestamp":"2015-10-22T14:15:16.999","webSocketServerUrl":"ws://devicehive.com"}`)

	info.WebsocketUrl = ""
	info.RestUrl = "https://devicehive.com"
	testCheckJson(t, info, `{"apiVersion":"1.2.3","serverTimestamp":"2015-10-22T14:15:16.999","restServerUrl":"https://devicehive.com"}`)
}
Пример #2
0
// Process GetServerInfo task
func (service *Service) processGetServerInfo(task *Task, info *core.ServerInfo) (err error) {
	// check response status
	err = task.CheckStatus()
	if err != nil {
		log.Warnf("WS: bad /info status (error: %s)", err)
		return
	}

	// parse response
	err = info.AssignJSON(task.dataRecved["info"])
	if err != nil {
		log.Warnf("WS: failed to parse /info body (error: %s)", err)
		return
	}

	return
}