Ejemplo n.º 1
0
func bar(c *pakt.Context) (interface{}, error) {
	// Decode the received data from the peer to the dummy value.
	var data string
	err := c.Decode(&data)
	if err != nil {
		// The remote peer would get this error.
		return nil, err
	}

	// Log.
	log.Printf("received data from server: %+v", data)

	// Close the socket and exit the application after a short timeout.
	go func() {
		time.Sleep(500 * time.Millisecond)
		c.Socket().Close()
	}()

	// Just send the data back to the client.
	return data, nil
}