File: /var/www/vhost/disk-apps/pwa.sports-crowd.com/src/app/services/pusher.service.ts
import { HttpClient } from "@angular/common/http";
import { Injectable } from "@angular/core";
import Pusher from "pusher-js";
import { ApiService } from "./api.service";
@Injectable({
providedIn: "root",
})
export class PusherService {
private chatChannel: any;
private OrderChannel: any;
pusher;
constructor(public http: HttpClient, private api: ApiService) {
this.pusher = new Pusher("12a176ecc75eb053049a", {
cluster: "us2",
authEndpoint: this.api.getUrl() + "/api/pusher/auth",
});
}
disconnectChat() {
this.pusher.unsubscribe("chat-channel");
}
connectChat() {
this.chatChannel = this.pusher.subscribe("chat-channel");
}
getChatChannel() {
return this.chatChannel;
}
connectOrderState() {
this.OrderChannel = this.pusher.subscribe("order-channel-state");
}
disconnectOrderState() {
this.pusher.unsubscribe("order-channel-state");
}
getOrderChannel() {
return this.OrderChannel;
}
}