Commit 1f34ee8863864d590dc0e7965cc4de2a8c2be505

Authored by Lars Tiede
0 parents

after presentation

code/README.md 0 → 100644
  1 +++ a/code/README.md
  1 +To build the server, have go installed and set up, and type
  2 +
  3 + $ go build
  4 +
  5 +The executable file will be named "code" because I was lazy.
... ...
code/client.html 0 → 100644
  1 +++ a/code/client.html
  1 +<html>
  2 +<body>
  3 +<p id="output_number"></p>
  4 +</body>
  5 +
  6 +<script type="text/javascript">
  7 +window.onload = function() {
  8 + var out = document.getElementById("output_number");
  9 + var ws = new WebSocket("ws://localhost:4040/ws_demo");
  10 +
  11 + ws.onopen = function() {
  12 + ws.send("1000");
  13 + };
  14 +
  15 + ws.onmessage = function(msg) {
  16 + out.innerHTML = msg.data;
  17 + };
  18 +};
  19 +</script>
  20 +
  21 +</html>
... ...
code/server.go 0 → 100644
  1 +++ a/code/server.go
  1 +package main
  2 +
  3 +import (
  4 + "fmt"
  5 + "net/http"
  6 + "strconv"
  7 + "time"
  8 +
  9 + "github.com/gorilla/mux"
  10 + "github.com/gorilla/websocket"
  11 +)
  12 +
  13 +func main() {
  14 + // set up and run http server
  15 + routes := mux.NewRouter()
  16 + routes.HandleFunc("/", serveHTMLFileHandler)
  17 + routes.HandleFunc("/ws_demo", websocketHandler)
  18 + http.ListenAndServe("localhost:4040", routes)
  19 +}
  20 +
  21 +func serveHTMLFileHandler(w http.ResponseWriter, r *http.Request) {
  22 + http.ServeFile(w, r, "./client.html")
  23 +}
  24 +
  25 +func websocketHandler(w http.ResponseWriter, r *http.Request) {
  26 + // "upgrade" http connection to websocket connection
  27 + upgrader := websocket.Upgrader{}
  28 + conn, err := upgrader.Upgrade(w, r, nil)
  29 + if err != nil {
  30 + fmt.Println(err)
  31 + return
  32 + }
  33 +
  34 + // read number from client
  35 + _, textFromClient, err := conn.ReadMessage()
  36 + if err != nil {
  37 + return
  38 + }
  39 + number, _ := strconv.ParseInt(string(textFromClient), 10, 64)
  40 +
  41 + // until connection is closed by client, increment number and send
  42 + // it to the client, once every second
  43 + for {
  44 + number += 1
  45 + time.Sleep(1 * time.Second)
  46 + err = conn.WriteMessage(websocket.TextMessage, []byte(fmt.Sprintf("%d", number)))
  47 + if err != nil { // this happens when connection has been closed
  48 + return
  49 + }
  50 + }
  51 +}
... ...
presentation.key/Data/110809_FamilyChineseOahu_EN_00317_2040x1360-small-12.jpg 0 → 100644

23.7 KB

presentation.key/Data/110809_FamilyChineseOahu_EN_02016_981x654-small-14.jpg 0 → 100644

23.7 KB

presentation.key/Data/110809_FamilyChineseOahu_EN_02390_2880x1921-small-10.jpg 0 → 100644

28.2 KB

presentation.key/Data/mt10@2x-87.jpg 0 → 100644

34.9 KB

presentation.key/Data/mt1@2x-78.jpg 0 → 100644

25.8 KB

presentation.key/Data/mt2@2x-79.jpg 0 → 100644

8.41 KB

presentation.key/Data/mt3@2x-80.jpg 0 → 100644

17.4 KB

presentation.key/Data/mt4@2x-81.jpg 0 → 100644

8.67 KB

presentation.key/Data/mt5@2x-107.jpg 0 → 100644

18.8 KB

presentation.key/Data/mt6@2x-83.jpg 0 → 100644

25.8 KB

presentation.key/Data/mt7@2x-84.jpg 0 → 100644

26.1 KB

presentation.key/Data/mt8@2x-85.jpg 0 → 100644

26.1 KB

presentation.key/Data/mt9@2x-86.jpg 0 → 100644

6.98 KB

presentation.key/Data/st0-1937.jpg 0 → 100644

4.79 KB

presentation.key/Data/st1-4088.jpg 0 → 100644

20.9 KB

presentation.key/Data/st10-4081.jpg 0 → 100644

29.1 KB

presentation.key/Data/st10-5014.jpg 0 → 100644

26.7 KB

presentation.key/Data/st11-3968.jpg 0 → 100644

3.14 KB

presentation.key/Data/st11-5021.jpg 0 → 100644

26.2 KB

presentation.key/Data/st2-5164.jpg 0 → 100644

25.8 KB

presentation.key/Data/st3-3254.jpg 0 → 100644

2.66 KB

presentation.key/Data/st4-5174.jpg 0 → 100644

13.3 KB

presentation.key/Data/st5-5194.jpg 0 → 100644

26.1 KB

presentation.key/Data/st6-5232.jpg 0 → 100644

31.5 KB

presentation.key/Data/st7-5246.jpg 0 → 100644

31.3 KB

presentation.key/Data/st8-5263.jpg 0 → 100644

21 KB

presentation.key/Data/st9-5264.jpg 0 → 100644

23.8 KB

presentation.key/Index.zip 0 → 100644
No preview for this file type
presentation.key/Metadata/BuildVersionHistory.plist 0 → 100644
  1 +++ a/presentation.key/Metadata/BuildVersionHistory.plist
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3 +<plist version="1.0">
  4 +<array>
  5 + <string>Template: White (2014-02-28 09:41)</string>
  6 + <string>M6.2.2-1878-1</string>
  7 +</array>
  8 +</plist>
... ...
presentation.key/Metadata/DocumentIdentifier 0 → 100644
  1 +++ a/presentation.key/Metadata/DocumentIdentifier
  1 +158253F5-D8E3-4398-94CC-E8E57D304F05
0 2 \ No newline at end of file
... ...
presentation.key/Metadata/Properties.plist 0 → 100644
No preview for this file type
presentation.key/preview-micro.jpg 0 → 100644

924 Bytes

presentation.key/preview-web.jpg 0 → 100644

2.75 KB

presentation.key/preview.jpg 0 → 100644