import Api from '../../lib/socket-api'

export const api = Api('/', {
  // timeout: 10 * 1000,
  // keepConnection: 30000,
  socket: {secure: true, rejectUnauthorized: false, verify: false},
})

const logger = (data) => {
  console.log(data)
  return data
}

export const doAction = (action, data) => {
  return api[action]({data}).then(logger).then(({data}) => data)
}

api.on("disconnect", () => window.open(window.location,'_self').close());
