Merge pull request #1447 from thecodingmachine/fix_api_chat
Fixing broken chat API
This commit is contained in:
commit
7cf9f8ff10
@ -46,30 +46,18 @@ type AnswererCallback<T extends keyof IframeQueryMap> = (
|
|||||||
* Also allows to send messages to those iframes.
|
* Also allows to send messages to those iframes.
|
||||||
*/
|
*/
|
||||||
class IframeListener {
|
class IframeListener {
|
||||||
private readonly _readyStream: Subject<HTMLIFrameElement> = new Subject();
|
|
||||||
public readonly readyStream = this._readyStream.asObservable();
|
|
||||||
|
|
||||||
private readonly _chatStream: Subject<ChatEvent> = new Subject();
|
|
||||||
public readonly chatStream = this._chatStream.asObservable();
|
|
||||||
|
|
||||||
private readonly _openPopupStream: Subject<OpenPopupEvent> = new Subject();
|
private readonly _openPopupStream: Subject<OpenPopupEvent> = new Subject();
|
||||||
public readonly openPopupStream = this._openPopupStream.asObservable();
|
public readonly openPopupStream = this._openPopupStream.asObservable();
|
||||||
|
|
||||||
private readonly _openTabStream: Subject<OpenTabEvent> = new Subject();
|
private readonly _openTabStream: Subject<OpenTabEvent> = new Subject();
|
||||||
public readonly openTabStream = this._openTabStream.asObservable();
|
public readonly openTabStream = this._openTabStream.asObservable();
|
||||||
|
|
||||||
private readonly _goToPageStream: Subject<GoToPageEvent> = new Subject();
|
|
||||||
public readonly goToPageStream = this._goToPageStream.asObservable();
|
|
||||||
|
|
||||||
private readonly _loadPageStream: Subject<string> = new Subject();
|
private readonly _loadPageStream: Subject<string> = new Subject();
|
||||||
public readonly loadPageStream = this._loadPageStream.asObservable();
|
public readonly loadPageStream = this._loadPageStream.asObservable();
|
||||||
|
|
||||||
private readonly _openCoWebSiteStream: Subject<OpenCoWebSiteEvent> = new Subject();
|
private readonly _openCoWebSiteStream: Subject<OpenCoWebSiteEvent> = new Subject();
|
||||||
public readonly openCoWebSiteStream = this._openCoWebSiteStream.asObservable();
|
public readonly openCoWebSiteStream = this._openCoWebSiteStream.asObservable();
|
||||||
|
|
||||||
private readonly _closeCoWebSiteStream: Subject<void> = new Subject();
|
|
||||||
public readonly closeCoWebSiteStream = this._closeCoWebSiteStream.asObservable();
|
|
||||||
|
|
||||||
private readonly _disablePlayerControlStream: Subject<void> = new Subject();
|
private readonly _disablePlayerControlStream: Subject<void> = new Subject();
|
||||||
public readonly disablePlayerControlStream = this._disablePlayerControlStream.asObservable();
|
public readonly disablePlayerControlStream = this._disablePlayerControlStream.asObservable();
|
||||||
|
|
||||||
@ -219,7 +207,7 @@ class IframeListener {
|
|||||||
} else if (payload.type === "setProperty" && isSetPropertyEvent(payload.data)) {
|
} else if (payload.type === "setProperty" && isSetPropertyEvent(payload.data)) {
|
||||||
this._setPropertyStream.next(payload.data);
|
this._setPropertyStream.next(payload.data);
|
||||||
} else if (payload.type === "chat" && isChatEvent(payload.data)) {
|
} else if (payload.type === "chat" && isChatEvent(payload.data)) {
|
||||||
this._chatStream.next(payload.data);
|
scriptUtils.sendAnonymousChat(payload.data);
|
||||||
} else if (payload.type === "openPopup" && isOpenPopupEvent(payload.data)) {
|
} else if (payload.type === "openPopup" && isOpenPopupEvent(payload.data)) {
|
||||||
this._openPopupStream.next(payload.data);
|
this._openPopupStream.next(payload.data);
|
||||||
} else if (payload.type === "closePopup" && isClosePopupEvent(payload.data)) {
|
} else if (payload.type === "closePopup" && isClosePopupEvent(payload.data)) {
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
import { coWebsiteManager } from "../WebRtc/CoWebsiteManager";
|
import { coWebsiteManager } from "../WebRtc/CoWebsiteManager";
|
||||||
|
import { playersStore } from "../Stores/PlayersStore";
|
||||||
|
import { chatMessagesStore } from "../Stores/ChatStore";
|
||||||
|
import type { ChatEvent } from "./Events/ChatEvent";
|
||||||
|
|
||||||
class ScriptUtils {
|
class ScriptUtils {
|
||||||
public openTab(url: string) {
|
public openTab(url: string) {
|
||||||
@ -16,6 +19,11 @@ class ScriptUtils {
|
|||||||
public closeCoWebSite() {
|
public closeCoWebSite() {
|
||||||
coWebsiteManager.closeCoWebsite();
|
coWebsiteManager.closeCoWebsite();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sendAnonymousChat(chatEvent: ChatEvent) {
|
||||||
|
const userId = playersStore.addFacticePlayer(chatEvent.author);
|
||||||
|
chatMessagesStore.addExternalMessage(userId, chatEvent.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const scriptUtils = new ScriptUtils();
|
export const scriptUtils = new ScriptUtils();
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
import { iframeListener } from "../Api/IframeListener";
|
|
||||||
import { chatMessagesStore } from "../Stores/ChatStore";
|
|
||||||
import { playersStore } from "../Stores/PlayersStore";
|
|
||||||
|
|
||||||
export class DiscussionManager {
|
|
||||||
constructor() {
|
|
||||||
iframeListener.chatStream.subscribe((chatEvent) => {
|
|
||||||
const userId = playersStore.addFacticePlayer(chatEvent.author);
|
|
||||||
chatMessagesStore.addExternalMessage(userId, chatEvent.message);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const discussionManager = new DiscussionManager();
|
|
@ -5,11 +5,7 @@ import { blackListManager } from "./BlackListManager";
|
|||||||
import type { Subscription } from "rxjs";
|
import type { Subscription } from "rxjs";
|
||||||
import type { UserSimplePeerInterface } from "./SimplePeer";
|
import type { UserSimplePeerInterface } from "./SimplePeer";
|
||||||
import { readable, Readable, Unsubscriber } from "svelte/store";
|
import { readable, Readable, Unsubscriber } from "svelte/store";
|
||||||
import {
|
import { localStreamStore, obtainedMediaConstraintStore, ObtainedMediaStreamConstraints } from "../Stores/MediaStore";
|
||||||
localStreamStore,
|
|
||||||
obtainedMediaConstraintStore,
|
|
||||||
ObtainedMediaStreamConstraints,
|
|
||||||
} from "../Stores/MediaStore";
|
|
||||||
import { playersStore } from "../Stores/PlayersStore";
|
import { playersStore } from "../Stores/PlayersStore";
|
||||||
import { chatMessagesStore, newChatMessageStore } from "../Stores/ChatStore";
|
import { chatMessagesStore, newChatMessageStore } from "../Stores/ChatStore";
|
||||||
import { getIceServersConfig } from "../Components/Video/utils";
|
import { getIceServersConfig } from "../Components/Video/utils";
|
||||||
|
Loading…
Reference in New Issue
Block a user