Connection make global connector by passed config The arguments are:
config
is a global config for all connections you haveconnectorName
is a name of global variable of connector(only for initialization Vue plugin)token
is a token for connectionshttpConfig
config for http connectionsserver
server for http connectionsport (optional)
port for http connections...axios settings
some axios settings
socketConfig
config for mqtt connections by socketserver
server for mqtt connectionsport (optional)
port for mqtt connectionsclientId (optional)
client id for mqtt connectionsmqttSettings
mqtt settings by MQTT.js API
let connector = new Connection({
token: 'FlespiToken xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
httpConfig: { server: 'https://server.io', port: 8080 },
socketConfig: { server: `ws://server.io`, mqttSettings: {
reschedulePings: true,
keepalive: 3600,
resubscribe: false,
reconnectPeriod: 5000,
connectTimeout: 3600000
}
}
})
- Token
let token = connector.token
connector.token = 'FlespiToken XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
- httpConfig
let httpConfig = connector.httpConfig
connector.httpConfig = { server: 'http://server.io', port: 80 }
- mqttConfig
let socketConfig = connector.socketConfig
connector.socketConfig = { server: 'ws://mqtt.server.io', mqttSettings: {
reschedulePings: true,
keepalive: 3600,
resubscribe: false,
reconnectPeriod: 5000,
connectTimeout: 3600000
}
}
- setRegion methods allows set flespi region for connection.
connector.setRegion(region)
/* region structure */
{
"cdn": "https://ru-cdn.flespi.io",
"default": false,
"gw": "ru-gw.flespi.io",
"mqtt": "ru-mqtt.flespi.io:8883",
"mqtt-ws": "ru-mqtt.flespi.io:443",
"region": "ru",
"rest": "https://ru.flespi.io"
}