package client import ( "fmt" "net/url" "path" "git.loafle.net/commons/logging-go" csswc "git.loafle.net/commons/server-go/socket/web/client" occc "git.loafle.net/overflow/commons-go/config/container" occp "git.loafle.net/overflow/commons-go/config/probe" ) func NewConnector(containerType occp.ContainerType, portNumber int) (*csswc.Connectors, error) { u := url.URL{ Scheme: "ws", Host: fmt.Sprintf("127.0.0.1:%d", portNumber), } u.Path = path.Join(u.Path, occc.HTTPEntry_Container) connector := &csswc.Connectors{ Name: containerType.String(), URL: u.String(), } connector.ReconnectInterval = 5 connector.ReconnectTryTime = 2 connector.MaxMessageSize = 4096 connector.ReadBufferSize = 4096 connector.WriteBufferSize = 4096 connector.PongTimeout = 60 connector.PingTimeout = 10 connector.PingPeriod = 9 connector.OnDisconnected = func(connector csc.Connector) { logging.Logger().Debugf("Client[%s] has been disconnected", connector.GetName()) } return connector, nil }