X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=main.go;fp=main.go;h=2dfd056d3610fc560f7b361569363d84108b230b;hb=00b5b83dcff4904aeb18760caa193fa3393241e0;hp=a6f8104e0e3081e467893386469bea1e6b9846ca;hpb=04040c928142db92d2ef2d4b43ad4701392e5ceb;p=src%2Fxds%2Fxds-cli.git diff --git a/main.go b/main.go index a6f8104..2dfd056 100644 --- a/main.go +++ b/main.go @@ -33,7 +33,6 @@ import ( "github.com/Sirupsen/logrus" "github.com/joho/godotenv" - socketio_client "github.com/sebd71/go-socket.io-client" "github.com/urfave/cli" ) @@ -71,8 +70,8 @@ var EnvConfFileMap map[string]string // HTTPCli Global variable that hold HTTP Client var HTTPCli *common.HTTPClient -// IOsk Global variable that hold SocketIo client -var IOsk *socketio_client.Client +// IOSkClient Global variable that hold SocketIo client +var IOSkClient *IOSockClient // exitError exists this program with the specified error func exitError(code int, f string, a ...interface{}) { @@ -96,6 +95,14 @@ func earlyDisplay() { earlyDebug = []string{} } +// LogSillyf Logging helper used for silly logging (printed on log.debug) +func LogSillyf(format string, args ...interface{}) { + sillyVal, sillyLog := os.LookupEnv("XDS_LOG_SILLY") + if sillyLog && sillyVal == "1" { + Log.Debugf("SILLY: "+format, args...) + } +} + // main func main() { @@ -382,23 +389,17 @@ func XdsConnInit(ctx *cli.Context) error { // Create io Websocket client Log.Debugln("Connecting IO.socket client on ", agentURL) - opts := &socketio_client.Options{ - Transport: "websocket", - Header: make(map[string][]string), - } - opts.Header["XDS-AGENT-SID"] = []string{HTTPCli.GetClientID()} - - IOsk, err = socketio_client.NewClient(agentURL, opts) + IOSkClient, err = NewIoSocketClient(agentURL, HTTPCli.GetClientID()) if err != nil { - return cli.NewExitError("IO.socket connection error: "+err.Error(), 1) + return cli.NewExitError(err.Error(), 1) } - IOsk.On("error", func(err error) { + IOSkClient.On("error", func(err error) { fmt.Println("ERROR Websocket: ", err.Error()) }) ctx.App.Metadata["httpCli"] = HTTPCli - ctx.App.Metadata["ioskCli"] = IOsk + ctx.App.Metadata["ioskCli"] = IOSkClient // Display version in logs (debug helpers) ver := xaapiv1.XDSVersion{}