기본 대기 런타임과 함께 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에서 답을 찾았습니다