-
Notifications
You must be signed in to change notification settings - Fork 140
Open
Description
package main
import (
"net/http"
"github.com/googollee/go-socket.io"
"listome.com/log"
)
func main() {
server, err := socketio.NewServer(nil)
if err != nil {
log.Fatal(err)
}
server.On("connection", func(so socketio.Socket) {
log.Info("on connection")
so.Join("paint_game")
so.On("paint", func(msg string) {
// log.Info("painting:", msg)
log.Info("broadcast:", so.BroadcastTo("paint_game", "painting", msg))
})
so.On("disconnection", func() {
log.Info("on disconnect")
})
})
server.On("error", func(so socketio.Socket, err error) {
log.Error("error:", err)
})
http.Handle("/socket.io/", server)
http.Handle("/", http.FileServer(http.Dir("./")))
log.Info("Serving at localhost:5000...")
log.Fatal(http.ListenAndServe(":5000", nil))
}godef -f main.go 'socketio.NewServer'
parseLocalPackage error: no more package files found
godef: no declaration found for socketio.NewServer
when I add import name,
package main
import (
"net/http"
socketio "github.com/googollee/go-socket.io"
"listome.com/log"
)
func main() {
server, err := socketio.NewServer(nil)
if err != nil {
log.Fatal(err)
}
server.On("connection", func(so socketio.Socket) {
log.Info("on connection")
so.Join("paint_game")
so.On("paint", func(msg string) {
// log.Info("painting:", msg)
log.Info("broadcast:", so.BroadcastTo("paint_game", "painting", msg))
})
so.On("disconnection", func() {
log.Info("on disconnect")
})
})
server.On("error", func(so socketio.Socket, err error) {
log.Error("error:", err)
})
http.Handle("/socket.io/", server)
http.Handle("/", http.FileServer(http.Dir("./")))
log.Info("Serving at localhost:5000...")
log.Fatal(http.ListenAndServe(":5000", nil))
}godef -f main.go 'socketio.NewServer'
/home/lstbao/work/listomego/src/github.com/googollee/go-socket.io/server.go:17:6
It can work well.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels