예제 #1
0
파일: hello.go 프로젝트: dnorman/scamp-go
func main() {
	scamp.Initialize()

	conn, err := scamp.Connect("127.0.0.1:30100")
	defer conn.Close()

	if err != nil {
		scamp.Error.Fatalf("could not connect! `%s`\n", err)
	}

	var sess *scamp.Session

	sess, err = conn.Send(scamp.Request{
		Action:         "sup.dude",
		EnvelopeFormat: scamp.ENVELOPE_JSON,
		Version:        1,
	})
	if err != nil {
		scamp.Error.Fatalf("error initiating session: `%s`", err)
	}

	reply, err := sess.RecvReply()
	if err != nil {
		scamp.Error.Fatalf("error receiving: `%s`", err)
	}
	scamp.Info.Printf("Got reply! `%s`", reply.Blob)
}
예제 #2
0
func main() {
	scamp.Initialize()

	conn, err := scamp.Connect("127.0.0.1:30101")
	defer conn.Close()

	if err != nil {
		scamp.Error.Fatalf("could not connect! `%s`\n", err)
	}

	var sess *scamp.Session

	inflight := make(chan bool, 500)

	for {
		inflight <- true

		go func() {
			sess, err = conn.Send(scamp.Request{
				Action:         "helloworld.hello",
				EnvelopeFormat: scamp.ENVELOPE_JSON,
				Version:        1,
			})
			if err != nil {
				scamp.Error.Fatalf("error initiating session: `%s`", err)
			}

			reply, err := sess.RecvReply()
			if err != nil {
				scamp.Error.Fatalf("error receiving: `%s`", err)
			}
			scamp.Info.Printf("Got reply! `%s`", reply.Blob)

			<-inflight
		}()
	}
}