Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oh sorry, wrong place to put a issue! #38

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Oh sorry, wrong place to put a issue! #38

wants to merge 7 commits into from

Conversation

odhs
Copy link

@odhs odhs commented Aug 17, 2018

In server examples we have:

server := gosocketio.NewServer(transport.GetDefaultWebsocketTransport())

But transport.GetDefaultWebsocketTransport() in package transport doesn't match with

func NewServer(tr transport.Transport) *Server in file server.go

Excerpt of the file wesocket.go in package transport:

/**
Returns websocket connection with default params
*/
func GetDefaultWebsocketTransport() *WebsocketTransport {
	return &WebsocketTransport{
		PingInterval:   WsDefaultPingInterval,
		PingTimeout:    WsDefaultPingTimeout,
		ReceiveTimeout: WsDefaultReceiveTimeout,
		SendTimeout:    WsDefaultSendTimeout,
		BufferSize:     WsDefaultBufferSize,
	}
}

Excerpt of the file transport.go in package transport:

/**
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)
}

Excerpt of the file server.go in package gosocketio, look the parameter is tr transport.Transport

/**
Create new socket.io server
*/
func NewServer(tr transport.Transport) *Server {
	s := Server{}
	s.initMethods()
	s.tr = tr
	s.channels = make(map[string]map[*Channel]struct{})
	s.rooms = make(map[*Channel]map[string]struct{})
	s.sids = make(map[string]*Channel)
	s.onConnection = onConnectStore
	s.onDisconnection = onDisconnectCleanup

	return &s
}

Excerpt of the file server.go in package main directory examples, look, the parameter doesn't match with func NewServer

func main() {
	server := gosocketio.NewServer(transport.GetDefaultWebsocketTransport())

	server.On(gosocketio.OnConnection, func(c *gosocketio.Channel) {
		log.Println("Connected")

		c.Emit("/message", Message{10, "main", "using emit"})

		c.Join("test")
		c.BroadcastTo("test", "/message", Message{10, "main", "using broadcast"})
	})
	server.On(gosocketio.OnDisconnection, func(c *gosocketio.Channel) {
		log.Println("Disconnected")
	})

	server.On("/join", func(c *gosocketio.Channel, channel Channel) string {
		time.Sleep(2 * time.Second)
		log.Println("Client joined to ", channel.Channel)
		return "joined to " + channel.Channel
	})

	serveMux := http.NewServeMux()
	serveMux.Handle("/socket.io/", server)

	log.Println("Starting server...")
	log.Panic(http.ListenAndServe(":3811", serveMux))
}

Thank you for attention

IronSinew and others added 7 commits November 8, 2017 10:42
Through some profiling under a fair amount of load, we found that on occasion the sidsLock would not release and cause channelsLock not not release as well since both are deferred. After offloading it to another goroutine, the issue subsided under load.
Prevent locks from becoming mutually exclusive
@odhs odhs changed the title GetDefaultWebsocketTransport doesn't return transport GetDefaultWebsocketTransport doesn't return Transport type Aug 17, 2018
@odhs odhs changed the title GetDefaultWebsocketTransport doesn't return Transport type Oh sorry, wrong place to put a issue! Aug 17, 2018
@odhs odhs closed this Aug 17, 2018
@odhs odhs reopened this Aug 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants