import { Component } from '@angular/core'; import { ChatService } from './chat.service'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { title = 'Sip Finders'; message: string; sip:any[]; PeerStatus:any={}; DialBegin:any={}; constructor(private chatService: ChatService) { } ngOnInit() { this.chatService .getMessages() .subscribe((message) => { console.log(message); if(message.sip){ this.sip=message.sip; }else if(message.PeerStatus){ this.PeerStatus=message.PeerStatus; for (let i of this.sip) { var ObjectName="SIP/"+i.ObjectName; if(ObjectName==this.PeerStatus.Peer){ if(this.PeerStatus.PeerStatus=="Unregistered"){ i.PeerStatus=this.PeerStatus.PeerStatus; }else if(this.PeerStatus.PeerStatus=="Registered") i.IPaddress=this.PeerStatus.Address; i.PeerStatus=this.PeerStatus.PeerStatus; } } }else if(message.DialBegin){ this.DialBegin=message.DialBegin; for (let i of this.sip) { if(i.ObjectName==this.DialBegin.From){ if(this.PeerStatus.PeerStatus=="Outgoing"){ i.PeerStatus=this.PeerStatus.PeerStatus; }else if(this.PeerStatus.PeerStatus=="Incomming") i.IPaddress=this.PeerStatus.Address; i.PeerStatus=this.PeerStatus.PeerStatus; } } console.log(message); } }); } sendMessage() { this.chatService.sendMessage(this.message); this.message = ''; } }