Ejemplo n.º 1
0
func (c *CreateReq) processCS() (interface{}, error) {
	log.Printf("[processCS] src: %s", spew.Sdump(c))
	rqst, _ := c.toCreateCS()
	resp, _ := rqst.Process()
	ourResp, _ := fromCreateCS(resp)

	return ourResp, nil
}
Ejemplo n.º 2
0
func (c *SearchReq) processCS() (interface{}, error) {
	log.Printf("[processCS] src: %s", spew.Sdump(c))
	// rqst, _ := c.toCSSearchLL()
	// resp, _ := rqst.Process()
	// ourResp, _ := fromSearchCS(resp)

	// return ourResp, nil

	return nil, nil
}
Ejemplo n.º 3
0
func main() {
	client, err := rpc.DialHTTP("tcp", ":1234")
	if err != nil {
		log.Print("dialing:", err)
	}
	// Synchronous call
	args := &Args{7, 8}
	var reply int
	err = client.Call("Arith.Multiply", args, &reply)
	if err != nil {
		log.Print("arith error:", err)
	}
	fmt.Printf("Arith: %d*%d=%d\n", args.A, args.B, reply)

	// Synchronous call
	args = &Args{99, 11}
	var quo Quotient
	err = client.Call("Arith.Divide", args, &quo)
	if err != nil {
		log.Print("arith error:", err)
	}
	fmt.Printf("Arith: %d/%d=%v rmd: %v\n", args.A, args.B, quo.Quo, quo.Rem)

	// Synchronous call
	args = &Args{99, 10}
	err = client.Call("Arith.Divide", args, &quo)
	if err != nil {
		log.Print("arith error:", err)
	}
	fmt.Printf("Arith: %d/%d=%v rmd: %v\n", args.A, args.B, quo.Quo, quo.Rem)

	// Synchronous call
	args = &Args{99, 0}
	err = client.Call("Arith.Divide", args, &quo)
	if err != nil {
		log.Print("arith error:", err)
	}
	fmt.Printf("Arith: %d/%d=%v rmd: %v\n", args.A, args.B, quo.Quo, quo.Rem)

	// creq := NServiceRequest{
	// 	City: "San Jose",
	// }
	// fmt.Printf("%+v\n", creq)
	// var cresp NServicesResponse
	// err = client.Call("Service.ServicesForCity", &creq, &cresp)
	// if err != nil {
	// 	log.Print("[Services] error: ", err)
	// }
	// fmt.Println(spew.Sdump(cresp))
	{
		creq := NServiceRequest{
			City: "San Jose",
		}
		fmt.Printf("%+v\n", creq)
		var cresp NServicesResponse
		replyCall := client.Go("Service.City", &creq, &cresp, nil)
		answer := <-replyCall.Done
		if replyCall.Error != nil {
			log.Print("[Create] error: ", err)
		}
		fmt.Println(spew.Sdump(answer))
		if answer.Error != nil {
			fmt.Printf("Error on API request: %s\n", answer.Error)
		} else {
			fmt.Printf("Return: %v\n", answer.Reply.(*NServicesResponse))
		}
	}

	{
		creq := NServiceRequest{
			City: "all",
		}
		fmt.Printf("%+v\n", creq)
		var cresp NServicesResponse
		replyCall := client.Go("Service.All", &creq, &cresp, nil)
		answer := <-replyCall.Done
		if replyCall.Error != nil {
			log.Print("[Create] error: ", err)
		}
		fmt.Println(spew.Sdump(answer))
		if answer.Error != nil {
			fmt.Printf("Error on API request: %s\n", answer.Error)
		} else {
			fmt.Printf("Return: %v\n", answer.Reply.(*NServicesResponse))
		}
	}

	// creq := NCreateRequest{
	// 	API: API{
	// 		APIAuthKey:        "a01234567890z",
	// 		APIRequestType:    "CreateThreeOneOne",
	// 		APIRequestVersion: "1.0",
	// 	},
	// 	Type:        "Illegal Dumping / Trash",
	// 	TypeID:      22,
	// 	DeviceType:  "iPhone",
	// 	DeviceModel: "6",
	// 	DeviceID:    "test1",
	// 	Latitude:    37.151198,
	// 	Longitude:   -121.602594,
	// 	FirstName:   "James",
	// 	LastName:    "Haskell",
	// 	Email:       "*****@*****.**",
	// 	Phone:       "4445556666",
	// 	IsAnonymous: false,
	// 	Description: "There's an tattered zebra stuck on the side of the  building.",
	// }
	// fmt.Printf("%+v\n", creq)
	// var cresp NCreateResponse
	// replyCall := client.Go("Create.Run", &creq, &cresp, nil)
	// answer := <-replyCall.Done
	// fmt.Println(spew.Sdump(replyCall))
	// if replyCall.Error != nil {
	// 	log.Print("[Create] error: ", err)
	// }
	// fmt.Printf("Message: %s\n%v\n", answer.Reply.(*NCreateResponse).Message, answer.Reply.(*NCreateResponse))
}