summaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2018-03-09 17:33:18 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2018-03-09 17:33:18 +0100
commit00b5b83dcff4904aeb18760caa193fa3393241e0 (patch)
tree447d4d5249e659de8c0a062559bb58f739220322 /main.go
parent04040c928142db92d2ef2d4b43ad4701392e5ceb (diff)
Fixed terminal output (support escape and control characters)
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
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{}