forked from graarh/golang-socketio
/
transport.go
51 lines (43 loc) · 867 Bytes
/
transport.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
package transport
import (
"net/http"
"time"
)
/**
End-point connection for given transport
*/
type Connection interface {
/**
Receive one more message, block until received
*/
GetMessage() (message string, err error)
/**
Send given message, block until sent
*/
WriteMessage(message string) error
/**
Close current connection
*/
Close()
/**
Get ping time interval and ping request timeout
*/
PingParams() (interval, timeout time.Duration)
}
/**
Connection factory for given transport
*/
type Transport interface {
/**
Get client connection
*/
Connect(url string) (conn Connection, err error)
/**
Handle one server connection
*/
HandleConnection(w http.ResponseWriter, r *http.Request) (conn Connection, err error)
/**
Serve HTTP request after making connection and events setup
*/
Serve(w http.ResponseWriter, r *http.Request)
}