2016-12-08 13 views
1

기본 대기 런타임과 함께 Play Framework에서 대기 재생 플러그인을 사용하고 있습니다. https://github.com/Atmosphere/atmosphere-play대기 경로에서 ManagedService로 경로를 지정하는 방법

자습서 에서처럼 ManagedService 주석으로 클래스를 설정하려고하지만 Play 라우터 파일을 통해 경로를 매핑하는 방법을 알 수 없으며 다른 사람을 찾을 수 없었습니다. 그렇지 않으면 이것을했습니다. 문서는이 단계를 완전히 건너 뛴다. 대기 클라이언트 스크립트를 통해 서버에 연결할 때 404 오류가 발생한다.

예제 코드 :

클라이언트
@ManagedService(path = "/poll") 
public class PostPoller { 
    ... 
} 

:

var socket = $.atmosphere; 
var subSocket; 
var transport = 'websocket'; 

// We are now ready to cut the request 
var request = { url: '/poll', 
    contentType : "application/json", 
    trackMessageLength : true, 
    shared : true, 
    transport : transport , 
    fallbackTransport: 'long-polling'}; 

가 어떻게 재생 라우터의 ManagedService에 대한 경로를 설정합니까?

import static org.atmosphere.play.AtmosphereCoordinator.instance; 

public class Application extends Controller { 

    @Inject 
    public Application(ApplicationLifecycle lifecycle) { 

     // replace PostPoller with the ManagedService class you are using 
     instance.discover(PostPoller.class).ready(); 

     lifecycle.addStopHook(() -> { 
      instance().shutdown(); 
      return CompletableFuture.completedFuture(null); 
     }); 

     ... 
    } 

    ... 
} 

https://github.com/Atmosphere/atmosphere-play/issues/39에서 답을 찾았습니다

답변

0

경우에는 다른 사람이 찾고있다, 나는 그것이 주요 응용 프로그램 컨트롤러에 다음을 추가하여 분위기 플레이 2.3.0에서 작업 얻을 수있었습니다.