// Golang Server
package main
import (
"net/http"
"fmt"
)
func loadin(w http.ResponseWriter, r *http.Request) {
username := r.FormValue("username")
password := r.FormValue("password")
fmt.Fprintf(w,"<html><body>");
fmt.Fprintf(w, "Hello, %s ! <br/>", username)
fmt.Fprintf(w, "Your password is : %s!", password)
fmt.Fprintf(w,"</body></html>");
}
func main() {
http.HandleFunc("/loadin", loadin)
http.ListenAndServe(":8080", nil)
}
// Unity C#
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
IEnumerator Start () {
WWWForm wwwF = new WWWForm ();
wwwF.AddField ("username","Loli");
wwwF.AddField ("password","Kitty");
WWW www = new WWW ("http://127.0.0.1:8080/loadin", wwwF);
yield return www;
print (www.text);
}
}
執行結果: