aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go27
1 files changed, 14 insertions, 13 deletions
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{}