2017-03-02 22:07:01 +00:00
|
|
|
import SockJS from 'sockjs-client';
|
|
|
|
|
|
|
|
import local from 'utilities/local';
|
|
|
|
|
|
|
|
export default (client) => {
|
|
|
|
return {
|
|
|
|
queries: {
|
|
|
|
run: (campaignID) => {
|
|
|
|
return new Promise((resolve) => {
|
2021-02-10 20:13:11 +00:00
|
|
|
const socket = new SockJS(`${client.baseURL}/v1/fleet/results`, undefined, {});
|
2017-03-02 22:07:01 +00:00
|
|
|
|
|
|
|
socket.onopen = () => {
|
|
|
|
socket.send(JSON.stringify({ type: 'auth', data: { token: local.getItem('auth_token') } }));
|
|
|
|
socket.send(JSON.stringify({ type: 'select_campaign', data: { campaign_id: campaignID } }));
|
|
|
|
};
|
|
|
|
|
|
|
|
return resolve(socket);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|