diff --git a/code/README.md b/code/README.md new file mode 100644 index 0000000..e17e49d --- /dev/null +++ b/code/README.md @@ -0,0 +1,5 @@ +To build the server, have go installed and set up, and type + + $ go build + +The executable file will be named "code" because I was lazy. diff --git a/code/client.html b/code/client.html new file mode 100644 index 0000000..0f2a666 --- /dev/null +++ b/code/client.html @@ -0,0 +1,21 @@ + + +

+ + + + + diff --git a/code/server.go b/code/server.go new file mode 100644 index 0000000..e3c5c83 --- /dev/null +++ b/code/server.go @@ -0,0 +1,51 @@ +package main + +import ( + "fmt" + "net/http" + "strconv" + "time" + + "github.com/gorilla/mux" + "github.com/gorilla/websocket" +) + +func main() { + // set up and run http server + routes := mux.NewRouter() + routes.HandleFunc("/", serveHTMLFileHandler) + routes.HandleFunc("/ws_demo", websocketHandler) + http.ListenAndServe("localhost:4040", routes) +} + +func serveHTMLFileHandler(w http.ResponseWriter, r *http.Request) { + http.ServeFile(w, r, "./client.html") +} + +func websocketHandler(w http.ResponseWriter, r *http.Request) { + // "upgrade" http connection to websocket connection + upgrader := websocket.Upgrader{} + conn, err := upgrader.Upgrade(w, r, nil) + if err != nil { + fmt.Println(err) + return + } + + // read number from client + _, textFromClient, err := conn.ReadMessage() + if err != nil { + return + } + number, _ := strconv.ParseInt(string(textFromClient), 10, 64) + + // until connection is closed by client, increment number and send + // it to the client, once every second + for { + number += 1 + time.Sleep(1 * time.Second) + err = conn.WriteMessage(websocket.TextMessage, []byte(fmt.Sprintf("%d", number))) + if err != nil { // this happens when connection has been closed + return + } + } +} diff --git a/presentation.key/Data/110809_FamilyChineseOahu_EN_00317_2040x1360-small-12.jpg b/presentation.key/Data/110809_FamilyChineseOahu_EN_00317_2040x1360-small-12.jpg new file mode 100644 index 0000000..9fa010e Binary files /dev/null and b/presentation.key/Data/110809_FamilyChineseOahu_EN_00317_2040x1360-small-12.jpg differ diff --git a/presentation.key/Data/110809_FamilyChineseOahu_EN_02016_981x654-small-14.jpg b/presentation.key/Data/110809_FamilyChineseOahu_EN_02016_981x654-small-14.jpg new file mode 100644 index 0000000..50e18ee Binary files /dev/null and b/presentation.key/Data/110809_FamilyChineseOahu_EN_02016_981x654-small-14.jpg differ diff --git a/presentation.key/Data/110809_FamilyChineseOahu_EN_02390_2880x1921-small-10.jpg b/presentation.key/Data/110809_FamilyChineseOahu_EN_02390_2880x1921-small-10.jpg new file mode 100644 index 0000000..a1b06ae Binary files /dev/null and b/presentation.key/Data/110809_FamilyChineseOahu_EN_02390_2880x1921-small-10.jpg differ diff --git a/presentation.key/Data/mt10@2x-87.jpg b/presentation.key/Data/mt10@2x-87.jpg new file mode 100644 index 0000000..d10ff91 Binary files /dev/null and b/presentation.key/Data/mt10@2x-87.jpg differ diff --git a/presentation.key/Data/mt1@2x-78.jpg b/presentation.key/Data/mt1@2x-78.jpg new file mode 100644 index 0000000..1d4cd89 Binary files /dev/null and b/presentation.key/Data/mt1@2x-78.jpg differ diff --git a/presentation.key/Data/mt2@2x-79.jpg b/presentation.key/Data/mt2@2x-79.jpg new file mode 100644 index 0000000..6243a92 Binary files /dev/null and b/presentation.key/Data/mt2@2x-79.jpg differ diff --git a/presentation.key/Data/mt3@2x-80.jpg b/presentation.key/Data/mt3@2x-80.jpg new file mode 100644 index 0000000..349fcbb Binary files /dev/null and b/presentation.key/Data/mt3@2x-80.jpg differ diff --git a/presentation.key/Data/mt4@2x-81.jpg b/presentation.key/Data/mt4@2x-81.jpg new file mode 100644 index 0000000..e11297c Binary files /dev/null and b/presentation.key/Data/mt4@2x-81.jpg differ diff --git a/presentation.key/Data/mt5@2x-107.jpg b/presentation.key/Data/mt5@2x-107.jpg new file mode 100644 index 0000000..54b01f1 Binary files /dev/null and b/presentation.key/Data/mt5@2x-107.jpg differ diff --git a/presentation.key/Data/mt6@2x-83.jpg b/presentation.key/Data/mt6@2x-83.jpg new file mode 100644 index 0000000..7315448 Binary files /dev/null and b/presentation.key/Data/mt6@2x-83.jpg differ diff --git a/presentation.key/Data/mt7@2x-84.jpg b/presentation.key/Data/mt7@2x-84.jpg new file mode 100644 index 0000000..e1ea76f Binary files /dev/null and b/presentation.key/Data/mt7@2x-84.jpg differ diff --git a/presentation.key/Data/mt8@2x-85.jpg b/presentation.key/Data/mt8@2x-85.jpg new file mode 100644 index 0000000..003b0f9 Binary files /dev/null and b/presentation.key/Data/mt8@2x-85.jpg differ diff --git a/presentation.key/Data/mt9@2x-86.jpg b/presentation.key/Data/mt9@2x-86.jpg new file mode 100644 index 0000000..b87a496 Binary files /dev/null and b/presentation.key/Data/mt9@2x-86.jpg differ diff --git a/presentation.key/Data/st0-1937.jpg b/presentation.key/Data/st0-1937.jpg new file mode 100644 index 0000000..aace26e Binary files /dev/null and b/presentation.key/Data/st0-1937.jpg differ diff --git a/presentation.key/Data/st1-4088.jpg b/presentation.key/Data/st1-4088.jpg new file mode 100644 index 0000000..060bf59 Binary files /dev/null and b/presentation.key/Data/st1-4088.jpg differ diff --git a/presentation.key/Data/st10-4081.jpg b/presentation.key/Data/st10-4081.jpg new file mode 100644 index 0000000..2724667 Binary files /dev/null and b/presentation.key/Data/st10-4081.jpg differ diff --git a/presentation.key/Data/st10-5014.jpg b/presentation.key/Data/st10-5014.jpg new file mode 100644 index 0000000..18cc4fa Binary files /dev/null and b/presentation.key/Data/st10-5014.jpg differ diff --git a/presentation.key/Data/st11-3968.jpg b/presentation.key/Data/st11-3968.jpg new file mode 100644 index 0000000..7d655b3 Binary files /dev/null and b/presentation.key/Data/st11-3968.jpg differ diff --git a/presentation.key/Data/st11-5021.jpg b/presentation.key/Data/st11-5021.jpg new file mode 100644 index 0000000..dfe8079 Binary files /dev/null and b/presentation.key/Data/st11-5021.jpg differ diff --git a/presentation.key/Data/st2-5164.jpg b/presentation.key/Data/st2-5164.jpg new file mode 100644 index 0000000..4980f10 Binary files /dev/null and b/presentation.key/Data/st2-5164.jpg differ diff --git a/presentation.key/Data/st3-3254.jpg b/presentation.key/Data/st3-3254.jpg new file mode 100644 index 0000000..7b2a2a9 Binary files /dev/null and b/presentation.key/Data/st3-3254.jpg differ diff --git a/presentation.key/Data/st4-5174.jpg b/presentation.key/Data/st4-5174.jpg new file mode 100644 index 0000000..357fdf0 Binary files /dev/null and b/presentation.key/Data/st4-5174.jpg differ diff --git a/presentation.key/Data/st5-5194.jpg b/presentation.key/Data/st5-5194.jpg new file mode 100644 index 0000000..e9eae67 Binary files /dev/null and b/presentation.key/Data/st5-5194.jpg differ diff --git a/presentation.key/Data/st6-5232.jpg b/presentation.key/Data/st6-5232.jpg new file mode 100644 index 0000000..b220d89 Binary files /dev/null and b/presentation.key/Data/st6-5232.jpg differ diff --git a/presentation.key/Data/st7-5246.jpg b/presentation.key/Data/st7-5246.jpg new file mode 100644 index 0000000..ec5fbe7 Binary files /dev/null and b/presentation.key/Data/st7-5246.jpg differ diff --git a/presentation.key/Data/st8-5263.jpg b/presentation.key/Data/st8-5263.jpg new file mode 100644 index 0000000..4db6895 Binary files /dev/null and b/presentation.key/Data/st8-5263.jpg differ diff --git a/presentation.key/Data/st9-5264.jpg b/presentation.key/Data/st9-5264.jpg new file mode 100644 index 0000000..8edfb73 Binary files /dev/null and b/presentation.key/Data/st9-5264.jpg differ diff --git a/presentation.key/Index.zip b/presentation.key/Index.zip new file mode 100644 index 0000000..4c3ba2a Binary files /dev/null and b/presentation.key/Index.zip differ diff --git a/presentation.key/Metadata/BuildVersionHistory.plist b/presentation.key/Metadata/BuildVersionHistory.plist new file mode 100644 index 0000000..39dd4fe --- /dev/null +++ b/presentation.key/Metadata/BuildVersionHistory.plist @@ -0,0 +1,8 @@ + + + + + Template: White (2014-02-28 09:41) + M6.2.2-1878-1 + + diff --git a/presentation.key/Metadata/DocumentIdentifier b/presentation.key/Metadata/DocumentIdentifier new file mode 100644 index 0000000..5c144cc --- /dev/null +++ b/presentation.key/Metadata/DocumentIdentifier @@ -0,0 +1 @@ +158253F5-D8E3-4398-94CC-E8E57D304F05 \ No newline at end of file diff --git a/presentation.key/Metadata/Properties.plist b/presentation.key/Metadata/Properties.plist new file mode 100644 index 0000000..e0406c5 Binary files /dev/null and b/presentation.key/Metadata/Properties.plist differ diff --git a/presentation.key/preview-micro.jpg b/presentation.key/preview-micro.jpg new file mode 100644 index 0000000..4002299 Binary files /dev/null and b/presentation.key/preview-micro.jpg differ diff --git a/presentation.key/preview-web.jpg b/presentation.key/preview-web.jpg new file mode 100644 index 0000000..879ef47 Binary files /dev/null and b/presentation.key/preview-web.jpg differ diff --git a/presentation.key/preview.jpg b/presentation.key/preview.jpg new file mode 100644 index 0000000..ede1264 Binary files /dev/null and b/presentation.key/preview.jpg differ diff --git a/presentation.pdf b/presentation.pdf new file mode 100644 index 0000000..df1c711 Binary files /dev/null and b/presentation.pdf differ -- libgit2 0.21.4