2014-11-06 6 views
1

PubNub의 구독 메시지 처리기를 시작하는 데 문제가 있습니다. 모바일 앱에서 메시지를 수신하는 웹 클라이언트에서 작업하고 있습니다. 최근까지이 코드는 정상적으로 작동했습니다. 내 휴대 전화에서 메시지를 보내고 웹 앱이 자동 업데이트되도록 할 수 있습니다. 그러나 지난 며칠 동안 웹 응용 프로그램은 더 이상 업데이트되지 않습니다.PubNub 구독 메시지 콜백이 실행되지 않음

CoffeeScript로 작성한 각도 응용 프로그램입니다. PubNub에 대한 모든 부트 스트래핑을 처리하는 MessageService이 있습니다. 내 서비스의 subscribe 메서드는 수신 대기 할 채널 이름으로 설정하려는 엔티티 id arg를 전달하고 messageHandler 인수를 통해 함수 참조를 전달합니다.

angular.module('exampleApp').service 'MessageService', ($http, $interval) -> 
    pubnub = null 
    subscribePromise = null 

    config = 
    subscribe_key: 'demo' 

    # Sanity check. This gets triggered upon connection with the correct 
    # channel name/entity id. 
    connectionHandler = -> 
    _.forOwn arguments, (arg) -> console.log arg 

    return { 
    getChats: (id) -> 
     # Calls an API to fetch all of the chat messages. These aren't transmitted over 
     # PubNub because we do other fun things to adhere to HIPAA compliance. 
     return $http.get 'path/to/api/endpoint/' + id 
    subscribe: (id, messageHandler) -> 
     pubnub = pubnub or PUBNUB.init config 
     pubnub.subscribe({ 
     channel: id 
     message: (data) -> 
      if not not subscribePromise 
      $interval.cancel subscribePromise 
      subscribePromise = null 
      messageHandler data 
     connect: connectionHandler 
     }) 

     # Interval-based workaround to function in spite of PubNub issue 
     subscribePromise = $interval messageHandler, 10000 
    } 

다음은 컨트롤러 중 하나에 구현 된 messageHandler의 예입니다.

angular.module('exampleApp').controller 'MessageCtrl', (MessageService) -> 
    $scope.messageId = 'some entity id' 

    # This message handler never gets fired, despite passing it to pubnub.subscribe 
    onMessageUpdated = (data) -> 
    console.log data 
    MessageService.getChats($scope.messageId).then (messages) -> $scope.messages = messages 

    MessageService.subscribe $scope.messageId, onMessageUpdated 

이전에 언급했듯이이 코드는 오래전부터 작동했지만 파란 색에서 메시지 처리기가 전혀 작동을 멈췄습니다. 1 달 넘게 그것을 건드리지 않았어. 나를 괴롭히는 것은 PubNub에서 dev 콘솔을 열어서 메시지가 전화기에서 들어오는 것을 볼 수 있지만, 어떤 이유로 메시지 처리기가 호출되지 않는 것입니다.

"edge"버전의 pubnub.js를 사용하고 있습니다. 따라서 구현을 망가뜨린 최신 업데이트가 있는지 궁금합니다. 여러분이 누락되거나 잘못 될 수 있다는 것을 다른 사람들이 볼 수 있습니까? 어떤 도움을 주셔서 감사합니다.

//

그냥 빨리 업데이트를 편집

. 3.5.47까지 롤백을 시도했지만 여전히 동작이 변경되지 않았습니다. 앵귤러의 $interval 서비스를 사용하여 빠른 해결 방법을 코딩하여이 문제를 파악하는 동안 앱이 최소한 작동하도록했습니다. 관련 변경 사항이있는 위의 코드 예제를 업데이트했습니다.

+1

빠른 수정 프로그램은 다음과 같이 PubNub.js 파일 버전을 사용할 수 있습니다.' 아마! :-) – PubNub

+0

다시 안녕하세요! PubNub JS SDK의 특정 버전 ID를 설정하여 문제가 해결되는지 알려주십시오. – PubNub

+0

API의 3.6.5를 시도했지만 다른 방법을 알려주고 어떻게 작동되는지 알려 드리겠습니다. – JasonOffutt

답변

0

빠른 업데이트. 몇 가지 다른 작업으로 옮겨서 1 년 정도 후에 다시 돌아온 후에 우리는 그 문제에 또 다른 찔림을 만들기로 결정했습니다. 인터벌 기반 폴링은 위에서 설명한대로 초기 구현시 잘 작동했지만 더 강력한 기능 세트가 필요합니다.

어쨌든 우리는 JS 클라이언트 (3.7.21)의 최신 안정 버전을 얻었으며 지금까지 문제가 해결 된 것으로 보입니다.

관련 문제