Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
init() {
// Log only if env is testing or development.
Pusher.logToConsole = CONSTANTS.PUSHER.logToConsole || true;
// Init Pusher
const options = {
encrypted: true,
app: window.WOOT,
cluster: CONSTANTS.PUSHER.cluster,
};
const pusher = new VuePusher(CONSTANTS.PUSHER.token, options);
// Add to global Obj
if (AuthAPI.isLoggedIn()) {
pusher.subscribe(AuthAPI.getPubSubToken());
return pusher.pusher;
}
return null;
},
};
import React from "react";
import Pusher from "pusher-js";
import { PUSHER_CONFIG } from "./config/pusher.config";
import "./App.css";
import { PusherProvider } from "./PusherContext";
import { Child } from "./Child";
// Enable pusher logging - don't include this in production
Pusher.logToConsole = true;
// Set up pusher instance with main channel subscription
// Be able to subscribe to the same channel in another component
// with separate callback but utilizing the existing connection
const pusher = new Pusher(PUSHER_CONFIG.key, {
cluster: PUSHER_CONFIG.cluster,
forceTLS: true
});
function App() {
return (
<div>
<header>Context API w/ Pusher real-time</header>
<main>
<span>Put some main component here</span></main></div>
const getPusher = (url) => {
Pusher.logToConsole = true;
Pusher.Runtime.createXHR = () => {
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
return xhr;
};
const pusher = new Pusher(params.PUSHER_KEY, {
cluster: params.PUSHER_CLUSTER,
authEndpoint: url,
auth: {
headers: {
'Content-Type': 'application/json',
'X-XSRF-TOKEN': Cookies.get('XSRF-TOKEN'),
},
},
private subscribePusher(user: User): void {
Pusher.logToConsole = !environment.pusherLogDisabled;
this.pusher = new Pusher(environment.pusherKey, {
cluster: environment.pusherCluster,
authEndpoint: `${environment.apiUrl}/rest/pusher`,
auth: {
headers: {
Authorization: `Bearer ${this.authService.getAccessToken()}`,
},
},
});
this.channel = this.pusher.subscribe('private-' + user.id);
this.bindOrganizationEvents();
this.bindProjectEvents();
this.bindViewEvents();
this.bindCollectionEvents();