Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1071)

Side by Side Diff: present/local.go

Issue 93030043: code review 93030043: go.talks/present: use new socket interface (Closed)
Patch Set: diff -r bb47523571ee https://code.google.com/p/go.talks Created 9 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Go Authors. All rights reserved. 1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // +build !appengine 5 // +build !appengine
6 6
7 package main 7 package main
8 8
9 import ( 9 import (
10 "flag" 10 "flag"
11 "fmt" 11 "fmt"
12 "go/build" 12 "go/build"
13 "log" 13 "log"
14 "net"
14 "net/http" 15 "net/http"
16 "net/url"
15 "os" 17 "os"
16 "runtime" 18 "runtime"
17 "strings" 19 "strings"
18 20
19 "code.google.com/p/go.tools/playground/socket" 21 "code.google.com/p/go.tools/playground/socket"
20 "code.google.com/p/go.tools/present" 22 "code.google.com/p/go.tools/present"
21 ) 23 )
22 24
23 const basePkg = "code.google.com/p/go.talks/present" 25 const basePkg = "code.google.com/p/go.talks/present"
24 26
(...skipping 23 matching lines...) Expand all
48 if nativeClient { 50 if nativeClient {
49 socket.RunScripts = false 51 socket.RunScripts = false
50 socket.Environ = func() []string { 52 socket.Environ = func() []string {
51 if runtime.GOARCH == "amd64" { 53 if runtime.GOARCH == "amd64" {
52 return environ("GOOS=nacl", "GOARCH=amd6 4p32") 54 return environ("GOOS=nacl", "GOARCH=amd6 4p32")
53 } 55 }
54 return environ("GOOS=nacl") 56 return environ("GOOS=nacl")
55 } 57 }
56 } 58 }
57 playScript(basePath, "SocketTransport") 59 playScript(basePath, "SocketTransport")
58 » » http.Handle("/socket", socket.Handler) 60
61 » » host, port, err := net.SplitHostPort(*httpListen)
62 » » if err != nil {
63 » » » log.Fatal(err)
64 » » }
65 » » origin := &url.URL{Scheme: "http", Host: host + ":" + port}
bradfitz 2014/05/05 16:52:49 JoinHostPort?
66 » » http.Handle("/socket", socket.NewHandler(origin))
59 } 67 }
60 http.Handle("/static/", http.FileServer(http.Dir(basePath))) 68 http.Handle("/static/", http.FileServer(http.Dir(basePath)))
61 69
62 if !strings.HasPrefix(*httpListen, "127.0.0.1") && 70 if !strings.HasPrefix(*httpListen, "127.0.0.1") &&
63 !strings.HasPrefix(*httpListen, "localhost") && 71 !strings.HasPrefix(*httpListen, "localhost") &&
64 present.PlayEnabled && !nativeClient { 72 present.PlayEnabled && !nativeClient {
65 log.Print(localhostWarning) 73 log.Print(localhostWarning)
66 } 74 }
67 75
68 log.Printf("Open your web browser and visit http://%s/", *httpListen) 76 log.Printf("Open your web browser and visit http://%s/", *httpListen)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 The present server appears to be listening on an address that is not localhost. 113 The present server appears to be listening on an address that is not localhost.
106 Anyone with access to this address and port will have access to this machine as 114 Anyone with access to this address and port will have access to this machine as
107 the user running present. 115 the user running present.
108 116
109 To avoid this message, listen on localhost or run with -play=false. 117 To avoid this message, listen on localhost or run with -play=false.
110 118
111 If you don't understand this message, hit Control-C to terminate this process. 119 If you don't understand this message, hit Control-C to terminate this process.
112 120
113 WARNING! WARNING! WARNING! 121 WARNING! WARNING! WARNING!
114 ` 122 `
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b