-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.go
34 lines (28 loc) · 801 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"log"
"net/http"
"golang.org/x/net/websocket"
"github.com/amrav/sparrow/client"
"github.com/amrav/sparrow/proto"
"github.com/amrav/sparrow/server"
"github.com/pkg/profile"
)
func main() {
defer profile.Start().Stop()
c := client.New()
c.StartActiveMode()
c.SetNick(proto.GenerateRandomUsername())
c.Connect("10.109.49.49:411")
http.Handle("/connect", websocket.Handler(func(conn *websocket.Conn) {
s := server.New(c)
s.Register("", SendHubMessages)
s.Register("", SendPrivateMessages)
s.Register("", HandleSearchResults)
s.Register("MAKE_SEARCH_QUERY", HandleSearchRequests)
s.Register("DOWNLOAD_FILE", HandleDownloadFile)
s.WsHandler(conn)
}))
http.Handle("/", http.FileServer(http.Dir("ui")))
log.Fatal(http.ListenAndServe(":12345", nil))
}