Search in sources :

Example 1 with Channel

use of sonia.scm.sse.Channel in project scm-review-plugin by scm-manager.

the class EventListener method handle.

@Subscribe
public void handle(BasicPullRequestEvent event) {
    Channel channel = channel(event);
    channel.broadcast(message(event));
}
Also used : Channel(sonia.scm.sse.Channel) Subscribe(com.github.legman.Subscribe)

Example 2 with Channel

use of sonia.scm.sse.Channel in project scm-review-plugin by scm-manager.

the class PullRequestResource method events.

@GET
@Path("events")
@SseResponse
@Operation(summary = "Register SSE", hidden = true)
@Produces(MediaType.SERVER_SENT_EVENTS)
public void events(@Context Sse sse, @Context SseEventSink eventSink, @BeanParam EventSubscriptionRequest request) {
    Repository repository = service.getRepository(request.getNamespace(), request.getName());
    PermissionCheck.checkRead(repository);
    PullRequest pullRequest = service.get(repository, request.getPullRequestId());
    Channel channel = channelRegistry.channel(new ChannelId(repository, pullRequest));
    channel.register(new Registration(request.getSessionId(), sse, eventSink));
}
Also used : Repository(sonia.scm.repository.Repository) Registration(sonia.scm.sse.Registration) PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest) Channel(sonia.scm.sse.Channel) ChannelId(com.cloudogu.scm.review.events.ChannelId) Path(javax.ws.rs.Path) SseResponse(sonia.scm.sse.SseResponse) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Operation(io.swagger.v3.oas.annotations.Operation)

Aggregations

Channel (sonia.scm.sse.Channel)2 ChannelId (com.cloudogu.scm.review.events.ChannelId)1 PullRequest (com.cloudogu.scm.review.pullrequest.service.PullRequest)1 Subscribe (com.github.legman.Subscribe)1 Operation (io.swagger.v3.oas.annotations.Operation)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Repository (sonia.scm.repository.Repository)1 Registration (sonia.scm.sse.Registration)1 SseResponse (sonia.scm.sse.SseResponse)1