Skip to content

Commit 1642735

Browse files
init project
0 parents  commit 1642735

18 files changed

+2101
-0
lines changed

.gitignore

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
2+
# Created by https://www.gitignore.io/api/go,macos,intellij+all
3+
# Edit at https://www.gitignore.io/?templates=go,macos,intellij+all
4+
5+
### Go ###
6+
# Binaries for programs and plugins
7+
*.exe
8+
*.exe~
9+
*.dll
10+
*.so
11+
*.dylib
12+
13+
# Test binary, built with `go test -c`
14+
*.test
15+
16+
# Output of the go coverage tool, specifically when used with LiteIDE
17+
*.out
18+
19+
# Dependency directories (remove the comment below to include it)
20+
# vendor/
21+
22+
### Go Patch ###
23+
/vendor/
24+
/Godeps/
25+
26+
### Intellij+all ###
27+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
28+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
29+
30+
# User-specific stuff
31+
.idea/**/workspace.xml
32+
.idea/**/tasks.xml
33+
.idea/**/usage.statistics.xml
34+
.idea/**/dictionaries
35+
.idea/**/shelf
36+
37+
# Generated files
38+
.idea/**/contentModel.xml
39+
40+
# Sensitive or high-churn files
41+
.idea/**/dataSources/
42+
.idea/**/dataSources.ids
43+
.idea/**/dataSources.local.xml
44+
.idea/**/sqlDataSources.xml
45+
.idea/**/dynamic.xml
46+
.idea/**/uiDesigner.xml
47+
.idea/**/dbnavigator.xml
48+
49+
# Gradle
50+
.idea/**/gradle.xml
51+
.idea/**/libraries
52+
53+
# Gradle and Maven with auto-import
54+
# When using Gradle or Maven with auto-import, you should exclude module files,
55+
# since they will be recreated, and may cause churn. Uncomment if using
56+
# auto-import.
57+
# .idea/modules.xml
58+
# .idea/*.iml
59+
# .idea/modules
60+
# *.iml
61+
# *.ipr
62+
63+
# CMake
64+
cmake-build-*/
65+
66+
# Mongo Explorer plugin
67+
.idea/**/mongoSettings.xml
68+
69+
# File-based project format
70+
*.iws
71+
72+
# IntelliJ
73+
out/
74+
75+
# mpeltonen/sbt-idea plugin
76+
.idea_modules/
77+
78+
# JIRA plugin
79+
atlassian-ide-plugin.xml
80+
81+
# Cursive Clojure plugin
82+
.idea/replstate.xml
83+
84+
# Crashlytics plugin (for Android Studio and IntelliJ)
85+
com_crashlytics_export_strings.xml
86+
crashlytics.properties
87+
crashlytics-build.properties
88+
fabric.properties
89+
90+
# Editor-based Rest Client
91+
.idea/httpRequests
92+
93+
# Android studio 3.1+ serialized cache file
94+
.idea/caches/build_file_checksums.ser
95+
96+
### Intellij+all Patch ###
97+
# Ignores the whole .idea folder and all .iml files
98+
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
99+
100+
.idea/
101+
102+
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
103+
104+
*.iml
105+
modules.xml
106+
.idea/misc.xml
107+
*.ipr
108+
109+
# Sonarlint plugin
110+
.idea/sonarlint
111+
112+
### macOS ###
113+
# General
114+
.DS_Store
115+
.AppleDouble
116+
.LSOverride
117+
118+
# Icon must end with two \r
119+
Icon
120+
121+
# Thumbnails
122+
._*
123+
124+
# Files that might appear in the root of a volume
125+
.DocumentRevisions-V100
126+
.fseventsd
127+
.Spotlight-V100
128+
.TemporaryItems
129+
.Trashes
130+
.VolumeIcon.icns
131+
.com.apple.timemachine.donotpresent
132+
133+
# Directories potentially created on remote AFP share
134+
.AppleDB
135+
.AppleDesktop
136+
Network Trash Folder
137+
Temporary Items
138+
.apdisk
139+
140+
# End of https://www.gitignore.io/api/go,macos,intellij+all

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module message
2+
3+
go 1.12
4+
5+
require (
6+
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee // indirect
7+
github.com/gobwas/pool v0.2.0 // indirect
8+
github.com/gobwas/ws v1.0.2
9+
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd
10+
)

go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=
2+
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
3+
github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8=
4+
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
5+
github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo=
6+
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
7+
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd h1:DBH9mDw0zluJT/R+nGuV3jWFWLFaHyYZWD4tOT+cjn0=
8+
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

main.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"message/websocket"
7+
"net"
8+
)
9+
10+
func main() {
11+
websocket.Setup("8080",
12+
func(token string) bool {
13+
return len(token) > 12
14+
},
15+
func(ident string, msg string, conn net.Conn) {
16+
log.Printf("identifier: %s, msg: %s, conn %p", ident, msg, conn)
17+
err := websocket.SendMsgToId(ident, fmt.Sprintf("我收到了你的 '%s'", msg))
18+
if err != nil {
19+
fmt.Println(err)
20+
}
21+
},
22+
)
23+
}

message

6.79 MB
Binary file not shown.

0 commit comments

Comments
 (0)