-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_test.go
52 lines (41 loc) · 896 Bytes
/
client_test.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package eventsocket
import (
"fmt"
"testing"
"time"
)
type Nooper struct{}
func (n *Nooper) OnConnect(con *Connection) {
fmt.Println("Connected")
evt, err := con.Send("event", "plain", "HEARTBEAT")
if err != nil {
fmt.Println("ahn?")
return
}
fmt.Println(evt.Success)
}
func (n *Nooper) OnDisconnect(con *Connection) {
fmt.Println("disconnect")
}
func (n *Nooper) OnEvent(con *Connection, evt *Event) {
fmt.Println("event", evt.EventBody.Get("Event-Name"))
con.Send("quit")
}
func (n *Nooper) OnClose(con *Connection) {
fmt.Println("close")
}
func Test_Client(t *testing.T) {
t.Log("Test Basic Client")
client, err := CreateClient(ClientSettings{
Address: "localhost:8021",
Password: "fongopass",
Timeout: 1 * time.Second,
Listener: new(Nooper),
})
if err != nil {
fmt.Println("Something went wrong ", err)
}
if client != nil {
}
// client.Loop()
}