-var ch chan xsapiv1.SDK
-
-// Disconnection Channel used to notify XDS Server disconnection
-//type Disconnection struct {
-// error string
-// code int
-// svrConf ServerCfg
-//}
-
-// IOSockClient .
-type IOSockClient struct {
- URL string
- Conn *socketio_client.Client
- Options *socketio_client.Options
- EmitMutex *sync.Mutex
- Connected bool
- //ServerDiscoChan chan Disconnection
- EscapeKeys []byte
-}
-
-func NewIoSocketClient(url, clientID string) (*IOSockClient, error) {
-
- var err error
-
- sCli := &IOSockClient{
- URL: url,
- EmitMutex: &sync.Mutex{},
- Options: &socketio_client.Options{
- Transport: "websocket",
- Header: make(map[string][]string),
- },
- //ServerDiscoChan: make(chan Disconnection, 1),
- }
- sCli.Options.Header["XDS-SID"] = []string{clientID}
-
- sCli.Conn, err = socketio_client.NewClient(url, sCli.Options)
- if err != nil {
- return nil, fmt.Errorf("IO.socket connection error: " + err.Error())
- }
-
- sCli.Conn.On("connection", func() {
- sCli.Connected = true
- })
-
- sCli.Conn.On("disconnection", func(err error) {
- log.Printf("WS disconnection event with err: %v\n", err)
- sCli.Connected = false
- })