Add whisper event

This commit is contained in:
Bill 2021-07-02 03:17:29 -04:00
parent 63bc890fd6
commit fc3ff514ec
4 changed files with 48 additions and 3 deletions

View File

@ -0,0 +1,29 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetChatInputContentUpdateEvent extends RoomWidgetUpdateEvent
{
public static CHAT_INPUT_CONTENT: string = 'RWCICUE_CHAT_INPUT_CONTENT';
public static WHISPER: string = 'whisper';
public static SHOUT: string = 'shout';
private _chatMode: string = '';
private _userName: string = '';
constructor(k: string, _arg_2: string)
{
super(RoomWidgetChatInputContentUpdateEvent.CHAT_INPUT_CONTENT);
this._chatMode = k;
this._userName = _arg_2;
}
public get chatMode(): string
{
return this._chatMode;
}
public get userName(): string
{
return this._userName;
}
}

View File

@ -1,4 +1,5 @@
export * from './RoomWidgetAvatarInfoEvent';
export * from './RoomWidgetChatInputContentUpdateEvent';
export * from './RoomWidgetFloodControlEvent';
export * from './RoomWidgetObjectNameEvent';
export * from './RoomWidgetRoomEngineUpdateEvent';

View File

@ -3,7 +3,7 @@ import { GetConnection, GetRoomEngine, GetSessionDataManager, IsOwnerOfFurniture
import { WiredSelectObjectEvent } from '../../../events';
import { dispatchUiEvent } from '../../../hooks/events';
import { LocalizeText } from '../../../utils/LocalizeText';
import { RoomWidgetObjectNameEvent, RoomWidgetUpdateEvent, RoomWidgetUpdateInfostandFurniEvent, RoomWidgetUpdateInfostandPetEvent, RoomWidgetUpdateInfostandRentableBotEvent, RoomWidgetUpdateInfostandUserEvent } from '../events';
import { RoomWidgetChatInputContentUpdateEvent, RoomWidgetObjectNameEvent, RoomWidgetUpdateEvent, RoomWidgetUpdateInfostandFurniEvent, RoomWidgetUpdateInfostandPetEvent, RoomWidgetUpdateInfostandRentableBotEvent, RoomWidgetUpdateInfostandUserEvent } from '../events';
import { RoomWidgetChangeMottoMessage, RoomWidgetFurniActionMessage, RoomWidgetMessage, RoomWidgetRoomObjectMessage, RoomWidgetUserActionMessage } from '../messages';
import { RoomWidgetHandler } from './RoomWidgetHandler';
@ -82,7 +82,7 @@ export class RoomWidgetInfostandHandler extends RoomWidgetHandler
GetSessionDataManager().givePetRespect(userId);
break;
case RoomWidgetUserActionMessage.WHISPER_USER:
//this.container.eventDispatcher.dispatchEvent(new RoomWidgetChatInputContentUpdateEvent(RoomWidgetChatInputContentUpdateEvent.WHISPER, userData.name));
this.container.eventDispatcher.dispatchEvent(new RoomWidgetChatInputContentUpdateEvent(RoomWidgetChatInputContentUpdateEvent.WHISPER, userData.name));
break;
case RoomWidgetUserActionMessage.IGNORE_USER:
GetSessionDataManager().ignoreUser(userData.name);

View File

@ -4,7 +4,7 @@ import { GetConfiguration } from '../../../../api';
import { CreateEventDispatcherHook } from '../../../../hooks/events';
import { LocalizeText } from '../../../../utils/LocalizeText';
import { useRoomContext } from '../../context/RoomContext';
import { RoomWidgetRoomObjectUpdateEvent, RoomWidgetUpdateInfostandUserEvent } from '../../events';
import { RoomWidgetChatInputContentUpdateEvent, RoomWidgetRoomObjectUpdateEvent, RoomWidgetUpdateInfostandUserEvent } from '../../events';
import { RoomWidgetChatMessage, RoomWidgetChatTypingMessage } from '../../messages';
import { ChatInputViewProps } from './ChatInputView.types';
import { ChatInputStyleSelectorView } from './style-selector/ChatInputStyleSelectorView';
@ -199,6 +199,21 @@ export const ChatInputView: FC<ChatInputViewProps> = props =>
CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.PEER, eventDispatcher, onRoomWidgetUpdateInfostandUserEvent);
const onRoomWidgetChatInputContentUpdateEvent = useCallback((event: RoomWidgetChatInputContentUpdateEvent) =>
{
switch(event.chatMode)
{
case RoomWidgetChatInputContentUpdateEvent.WHISPER: {
setChatValue(`${ chatModeIdWhisper } ${ event.userName } `);
return;
}
case RoomWidgetChatInputContentUpdateEvent.SHOUT:
return;
}
}, [ chatModeIdWhisper ]);
CreateEventDispatcherHook(RoomWidgetChatInputContentUpdateEvent.CHAT_INPUT_CONTENT, eventDispatcher, onRoomWidgetChatInputContentUpdateEvent);
useEffect(() =>
{
if(isTyping)