File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed
Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 55"errors"
66"github.com/graarh/golang-socketio/protocol"
77"github.com/graarh/golang-socketio/transport"
8+ "net/http"
89"sync"
910"time"
1011)
@@ -47,8 +48,9 @@ type Channel struct {
4748
4849ack ackProcessor
4950
50- server * Server
51- ip string
51+ server * Server
52+ ip string
53+ requestHeader http.Header
5254}
5355
5456/**
@@ -150,7 +152,7 @@ outgoing messages loop, sends messages from channel to socket
150152func outLoop (c * Channel , m * methods ) error {
151153for {
152154outBufferLen := len (c .out )
153- if outBufferLen >= queueBufferSize - 1 {
155+ if outBufferLen >= queueBufferSize - 1 {
154156return CloseChannel (c , m , ErrorSocketOverflood )
155157} else if outBufferLen > int (queueBufferSize / 2 ) {
156158overfloodedLock .Lock ()
Original file line number Diff line number Diff line change @@ -39,11 +39,18 @@ type Server struct {
3939
4040/**
4141Get ip of socket client
42- */
42+ */
4343func (c * Channel ) Ip () string {
4444return c .ip
4545}
4646
47+ /**
48+ Get request header of this connection
49+ */
50+ func (c * Channel ) RequestHeader () http.Header {
51+ return c .requestHeader
52+ }
53+
4754/**
4855Get channel by it's sid
4956*/
@@ -279,7 +286,9 @@ func (s *Server) SendOpenSequence(c *Channel) {
279286/**
280287Setup event loop for given connection
281288*/
282- func (s * Server ) SetupEventLoop (conn transport.Connection , remoteAddr string ) {
289+ func (s * Server ) SetupEventLoop (conn transport.Connection , remoteAddr string ,
290+ requestHeader http.Header ) {
291+
283292interval , timeout := conn .PingParams ()
284293hdr := Header {
285294Sid : generateNewId (remoteAddr ),
@@ -291,6 +300,7 @@ func (s *Server) SetupEventLoop(conn transport.Connection, remoteAddr string) {
291300c := & Channel {}
292301c .conn = conn
293302c .ip = remoteAddr
303+ c .requestHeader = requestHeader
294304c .initChannel ()
295305
296306c .server = s
@@ -313,7 +323,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
313323return
314324}
315325
316- s .SetupEventLoop (conn , r .RemoteAddr )
326+ s .SetupEventLoop (conn , r .RemoteAddr , r . Header )
317327s .tr .Serve (w , r )
318328}
319329
You can’t perform that action at this time.
0 commit comments