forked from madari/go-socket.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
transport_flashsocket.go
62 lines (50 loc) · 1.62 KB
/
transport_flashsocket.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
53
54
55
56
57
58
59
60
61
62
package socketio
import (
"http"
"os"
)
// The flashsocket transport.
type flashsocketTransport struct {
wsTransport *websocketTransport
}
// Creates a new flashsocket transport with the given read and write timeouts.
func NewFlashsocketTransport(rtimeout, wtimeout int64) Transport {
return &flashsocketTransport{&websocketTransport{rtimeout, wtimeout}}
}
// Returns the resource name.
func (t *flashsocketTransport) Resource() string {
return "flashsocket"
}
// Creates a new socket that can be used with a connection.
func (t *flashsocketTransport) newSocket() socket {
return &flashsocketSocket{t: t, s: t.wsTransport.newSocket()}
}
// flashsocketTransport implements the transport interface for flashsockets
type flashsocketSocket struct {
t *flashsocketTransport // the transport configuration
s socket
}
// Transport returns the transport the socket is based on.
func (s *flashsocketSocket) Transport() Transport {
return s.t
}
// String returns the verbose representation of the socket.
func (s *flashsocketSocket) String() string {
return s.t.Resource()
}
// Accepts a http connection & request pair. It upgrades the connection and calls
// proceed if succesfull.
//
// TODO: Remove the ugly channels and timeouts. They should not be needed!
func (s *flashsocketSocket) accept(w http.ResponseWriter, req *http.Request, proceed func()) (err os.Error) {
return s.s.accept(w, req, proceed)
}
func (s *flashsocketSocket) Read(p []byte) (int, os.Error) {
return s.s.Read(p)
}
func (s *flashsocketSocket) Write(p []byte) (int, os.Error) {
return s.s.Write(p)
}
func (s *flashsocketSocket) Close() os.Error {
return s.s.Close()
}