Skip to content
This repository has been archived by the owner on Mar 6, 2020. It is now read-only.

Commit

Permalink
added WebSocketClientGoneException when client is gone
Browse files Browse the repository at this point in the history
  • Loading branch information
musketyr committed May 24, 2019
1 parent 95a3bc7 commit f210f25
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 1.1.0
version = 1.1.0.1
micronautVersion = 1.1.0
gruVersion = 0.8.0
druVersion = 0.6.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public void send(String connectionId, InputStream payload) {
.errorResponseHandler(new HttpResponseHandler<AmazonClientException>() {
@Override
public AmazonClientException handle(HttpResponse response) throws Exception {
if (response.getStatusCode() == 410) {
return new WebSocketClientGoneException("WebSocket client with id " + connectionId + " is already gone");
}
return new AmazonClientException("Exception publishing messages to WS endpoint "
+ " POST " + url + " "
+ response.getStatusCode() + ": "
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.agorapulse.micronaut.aws.apigateway.ws;

import com.amazonaws.AmazonClientException;

public class WebSocketClientGoneException extends AmazonClientException {

public WebSocketClientGoneException(String message, Throwable t) {
super(message, t);
}

public WebSocketClientGoneException(String message) {
super(message);
}

public WebSocketClientGoneException(Throwable t) {
super(t);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ class MessageSenderSpec extends Specification {
MessageSender defaultSender = ctx.getBean(MessageSender)
when:
defaultSender.send(CONNECTION_ID, PAYLOAD)
then:
thrown(WebSocketClientGoneException)
}

void 'test forbidden'() {
given:
prepareServerAndContext {
header('Authorization', Matchers.iterableWithSize(1))
called(1)
responds().code(403).body('Forbidden', ContentType.TEXT_PLAIN)
}
MessageSender defaultSender = ctx.getBean(MessageSender)
when:
defaultSender.send(CONNECTION_ID, PAYLOAD)
then:
thrown(AmazonClientException)
}
Expand Down

0 comments on commit f210f25

Please sign in to comment.