신호 서버가 실행 중입니다. 업데이트 된 정보가 계속 전송됩니다. 나는 태그앵귤러 2 클라이언트의 SignalR API가 알림을 수신하지 않습니다.
$.connection.hub.url = "http://localhost:8080/signalr";
// Declare a proxy to reference the hub.
var chat = $.connection.myHub;
// Create a function that the hub can call to broadcast messages.
chat.client.addMessage = function (name, message) {
// Html encode display name and message.
console.log ("chat.client.addMessage.index");
};
내에서 index.html을 코드를 다음했다 그리고 동일은 addMessage이 SignalR 허브 서버에서 호출
ngOnInit() {
jQuery.connection.hub.url = "http://localhost:8080/signalr";
// Declare a proxy to reference the hub.
var chat = jQuery.connection.myHub;
// Create a function that the hub can call to broadcast messages.
chat.client.addMessage = function (name, message) {
// Html encode display name and message.
console.log ("chat.client.addMessage.index"); ""
};
}
파일 구성 요소 TS에 추가됩니다
. 그리고 index.html에 등록 된 addMessage는 수신하지만 구성 요소 ts에 등록 된 함수는 수신하지 않습니다.
디버그에서이 함수가 두 위치에 모두 등록되어있는 것을 알 수있었습니다. 두 함수를 호출하는 서버와 다른 함수를 등록하려고했습니다. 그러나 두 경우 모두 구성 요소/유형 스크립트에 등록 된 함수는 호출되지 않습니다. 내가 일을 SIGR를 받고 비슷한 문제를 가지고 있지만 결국 일하러 가야 관리
다른 사람들에게 도움이되도록 아래의 답변을 허용 된 솔루션으로 제공해 주시겠습니까? –