6 changed files with 82 additions and 105 deletions
@ -0,0 +1,21 @@
|
||||
# Go parameters
|
||||
GOCMD=GO111MODULE=on go
|
||||
GOBUILD=$(GOCMD) build
|
||||
GOTEST=$(GOCMD) test
|
||||
|
||||
|
||||
all: build |
||||
build: |
||||
rm -rf target/
|
||||
mkdir target/
|
||||
cp etc/config.toml target/config.toml
|
||||
$(GOBUILD) -o target/texas cmd/main.go
|
||||
|
||||
clean: |
||||
rm -rf target/
|
||||
|
||||
run: |
||||
nohup target/texas -conf=target/config.toml -region=sh -zone=sh001 -deploy.env=dev -weight=10 2>&1 > target/texas.log &
|
||||
|
||||
stop: |
||||
pkill -f target/texas
|
||||
@ -1,43 +0,0 @@
|
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<title>websocket</title> |
||||
</head> |
||||
<body> |
||||
|
||||
<input type="text" id="uname"> |
||||
<button id="btn">连接</button> |
||||
|
||||
<script type="text/javascript"> |
||||
document.getElementById("btn").onclick = function() { |
||||
const uname = document.getElementById("uname").value |
||||
console.log(uname) |
||||
connect(uname) |
||||
} |
||||
function connect(uname) { |
||||
const ws = new WebSocket("ws://localhost:9999/ws") |
||||
|
||||
ws.onopen = (e) => { |
||||
console.log('open', e) |
||||
document.getElementById("uname").value = "" |
||||
document.getElementById("btn").innerText = '发送' |
||||
document.getElementById("btn").onclick = function () { |
||||
const msg = document.getElementById("uname").value |
||||
const token = "AgOjcdf3goeYDX3lwWWwkXtVpcrL-l2rX8csrRKgs3_-BC3JOx0l6nZU0MV25eIn" |
||||
ws.send(JSON.stringify({t: token})) |
||||
document.getElementById("uname").value = '' |
||||
} |
||||
} |
||||
|
||||
ws.onmessage = (e) => { |
||||
console.log('msg:', e.data) |
||||
} |
||||
|
||||
ws.onerror = (a,b,c) => { |
||||
console.log('error:', a, b, c) |
||||
} |
||||
} |
||||
</script> |
||||
</body> |
||||
</html> |
||||
Loading…
Reference in new issue