Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setTimeout(() => {
let replyMessage = new Message();
replyMessage.message = "You have typed '" + message.message + "'";
replyMessage.dateSent = new Date();
if (isNaN(message.toId))
{
let group = DemoAdapter.mockedParticipants.find(x => x.id == message.toId) as Group;
// Message to a group. Pick up any participant for this
let randomParticipantIndex = Math.floor(Math.random() * group.chattingTo.length);
replyMessage.fromId = group.chattingTo[randomParticipantIndex].id;
replyMessage.toId = message.toId;
this.onMessageReceived(group, replyMessage);
}
avatar: "https://66.media.tumblr.com/avatar_9dd9bb497b75_128.pnj",
status: ChatParticipantStatus.Online
},
{
participantType: ChatParticipantType.User,
id: 2,
displayName: "Cersei Lannister",
avatar: null,
status: ChatParticipantStatus.Online
},
{
participantType: ChatParticipantType.User,
id: 3,
displayName: "Daenerys Targaryen",
avatar: "https://68.media.tumblr.com/avatar_d28d7149f567_128.png",
status: ChatParticipantStatus.Busy
},
{
participantType: ChatParticipantType.User,
id: 4,
displayName: "Eddard Stark",
avatar: "https://pbs.twimg.com/profile_images/600707945911844864/MNogF757_400x400.jpg",
status: ChatParticipantStatus.Offline
},
{
participantType: ChatParticipantType.User,
id: 5,
displayName: "Hodor",
avatar: "https://pbs.twimg.com/profile_images/378800000449071678/27f2e27edd119a7133110f8635f2c130.jpeg",
status: ChatParticipantStatus.Offline
},
{
avatar: "https://pbs.twimg.com/profile_images/600707945911844864/MNogF757_400x400.jpg",
status: ChatParticipantStatus.Offline
},
{
participantType: ChatParticipantType.User,
id: 5,
displayName: "Hodor",
avatar: "https://pbs.twimg.com/profile_images/378800000449071678/27f2e27edd119a7133110f8635f2c130.jpeg",
status: ChatParticipantStatus.Offline
},
{
participantType: ChatParticipantType.User,
id: 6,
displayName: "Jaime Lannister",
avatar: "https://pbs.twimg.com/profile_images/378800000243930208/4fa8efadb63777ead29046d822606a57.jpeg",
status: ChatParticipantStatus.Busy
},
{
participantType: ChatParticipantType.User,
id: 7,
displayName: "John Snow",
avatar: "https://pbs.twimg.com/profile_images/3456602315/aad436e6fab77ef4098c7a5b86cac8e3.jpeg",
status: ChatParticipantStatus.Busy
},
{
participantType: ChatParticipantType.User,
id: 8,
displayName: "Lorde Petyr 'Littlefinger' Baelish",
avatar: "http://68.media.tumblr.com/avatar_ba75cbb26da7_128.png",
status: ChatParticipantStatus.Offline
},
{
avatar: "https://68.media.tumblr.com/avatar_d28d7149f567_128.png",
status: ChatParticipantStatus.Busy
},
{
participantType: ChatParticipantType.User,
id: 4,
displayName: "Eddard Stark",
avatar: "https://pbs.twimg.com/profile_images/600707945911844864/MNogF757_400x400.jpg",
status: ChatParticipantStatus.Offline
},
{
participantType: ChatParticipantType.User,
id: 5,
displayName: "Hodor",
avatar: "https://pbs.twimg.com/profile_images/378800000449071678/27f2e27edd119a7133110f8635f2c130.jpeg",
status: ChatParticipantStatus.Offline
},
{
participantType: ChatParticipantType.User,
id: 6,
displayName: "Jaime Lannister",
avatar: "https://pbs.twimg.com/profile_images/378800000243930208/4fa8efadb63777ead29046d822606a57.jpeg",
status: ChatParticipantStatus.Busy
},
{
participantType: ChatParticipantType.User,
id: 7,
displayName: "John Snow",
avatar: "https://pbs.twimg.com/profile_images/3456602315/aad436e6fab77ef4098c7a5b86cac8e3.jpeg",
status: ChatParticipantStatus.Busy
},
{
avatar: null,
status: ChatParticipantStatus.Online
},
{
participantType: ChatParticipantType.User,
id: 3,
displayName: "Daenerys Targaryen",
avatar: "https://68.media.tumblr.com/avatar_d28d7149f567_128.png",
status: ChatParticipantStatus.Busy
},
{
participantType: ChatParticipantType.User,
id: 4,
displayName: "Eddard Stark",
avatar: "https://pbs.twimg.com/profile_images/600707945911844864/MNogF757_400x400.jpg",
status: ChatParticipantStatus.Offline
},
{
participantType: ChatParticipantType.User,
id: 5,
displayName: "Hodor",
avatar: "https://pbs.twimg.com/profile_images/378800000449071678/27f2e27edd119a7133110f8635f2c130.jpeg",
status: ChatParticipantStatus.Offline
},
{
participantType: ChatParticipantType.User,
id: 6,
displayName: "Jaime Lannister",
avatar: "https://pbs.twimg.com/profile_images/378800000243930208/4fa8efadb63777ead29046d822606a57.jpeg",
status: ChatParticipantStatus.Busy
},
{
export class DemoAdapter extends ChatAdapter implements IChatGroupAdapter
{
public static mockedParticipants: IChatParticipant[] = [
{
participantType: ChatParticipantType.User,
id: 1,
displayName: "Arya Stark",
avatar: "https://66.media.tumblr.com/avatar_9dd9bb497b75_128.pnj",
status: ChatParticipantStatus.Online
},
{
participantType: ChatParticipantType.User,
id: 2,
displayName: "Cersei Lannister",
avatar: null,
status: ChatParticipantStatus.Online
},
{
participantType: ChatParticipantType.User,
id: 3,
displayName: "Daenerys Targaryen",
avatar: "https://68.media.tumblr.com/avatar_d28d7149f567_128.png",
status: ChatParticipantStatus.Busy
},
{
participantType: ChatParticipantType.User,
id: 4,
displayName: "Eddard Stark",
avatar: "https://pbs.twimg.com/profile_images/600707945911844864/MNogF757_400x400.jpg",
status: ChatParticipantStatus.Offline
},
{
import { ChatAdapter, IChatGroupAdapter, User, Group, Message, ChatParticipantStatus, ParticipantResponse, ParticipantMetadata, ChatParticipantType, IChatParticipant } from 'ng-chat';
import { Observable, of } from 'rxjs';
import { delay } from "rxjs/operators";
export class DemoAdapter extends ChatAdapter implements IChatGroupAdapter
{
public static mockedParticipants: IChatParticipant[] = [
{
participantType: ChatParticipantType.User,
id: 1,
displayName: "Arya Stark",
avatar: "https://66.media.tumblr.com/avatar_9dd9bb497b75_128.pnj",
status: ChatParticipantStatus.Online
},
{
participantType: ChatParticipantType.User,
id: 2,
displayName: "Cersei Lannister",
avatar: null,
status: ChatParticipantStatus.Online
},
{
participantType: ChatParticipantType.User,
id: 3,
displayName: "Daenerys Targaryen",
avatar: "https://68.media.tumblr.com/avatar_d28d7149f567_128.png",
status: ChatParticipantStatus.Busy
},
{
import { ChatAdapter, IChatGroupAdapter, User, Group, Message, ChatParticipantStatus, ParticipantResponse, ParticipantMetadata, ChatParticipantType, IChatParticipant } from 'ng-chat';
import { Observable, of } from 'rxjs';
import { delay } from "rxjs/operators";
export class DemoAdapter extends ChatAdapter implements IChatGroupAdapter
{
public static mockedParticipants: IChatParticipant[] = [
{
participantType: ChatParticipantType.User,
id: 1,
displayName: "Arya Stark",
avatar: "https://66.media.tumblr.com/avatar_9dd9bb497b75_128.pnj",
status: ChatParticipantStatus.Online
},
{
participantType: ChatParticipantType.User,
id: 2,
displayName: "Cersei Lannister",
avatar: null,
status: ChatParticipantStatus.Online
},
{
participantType: ChatParticipantType.User,
id: 3,
displayName: "Daenerys Targaryen",
{
participantType: ChatParticipantType.User,
id: 1,
displayName: "Arya Stark",
avatar: "https://66.media.tumblr.com/avatar_9dd9bb497b75_128.pnj",
status: ChatParticipantStatus.Online
},
{
participantType: ChatParticipantType.User,
id: 2,
displayName: "Cersei Lannister",
avatar: null,
status: ChatParticipantStatus.Online
},
{
participantType: ChatParticipantType.User,
id: 3,
displayName: "Daenerys Targaryen",
avatar: "https://68.media.tumblr.com/avatar_d28d7149f567_128.png",
status: ChatParticipantStatus.Busy
},
{
participantType: ChatParticipantType.User,
id: 4,
displayName: "Eddard Stark",
avatar: "https://pbs.twimg.com/profile_images/600707945911844864/MNogF757_400x400.jpg",
status: ChatParticipantStatus.Offline
},
{
participantType: ChatParticipantType.User,
id: 5,
displayName: "Hodor",
setTimeout(() => {
let replyMessage = new Message();
replyMessage.fromId = message.toId;
replyMessage.toId = message.fromId;
replyMessage.message = "You have typed '" + message.message + "'";
let user = DemoAdapter.mockedUsers.find(x => x.id == replyMessage.fromId);
this.onMessageReceived(user, replyMessage);
}, 1000);
}