This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am thomasjallerton on github. | |
* I am thomasallerton (https://keybase.io/thomasallerton) on keybase. | |
* I have a public key ASBkkbdF-ZZovVbmAZAAIdvdY8N0Wmug03C1xZ-x06GtJAo | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>nimbus-framework</groupId> | |
<artifactId>nimbus-example-websocket-chat</artifactId> | |
<version>1.0-SNAPSHOT</version> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WebSocketApiLocalDeployment { | |
@Test | |
public void localWebChat() { | |
LocalNimbusDeployment localNimbusDeployment = LocalNimbusDeployment.getNewInstance("com.nimbusframework.examples.webchat"); | |
localNimbusDeployment.startAllServers(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WebSocketApiTest { | |
@Test | |
public void onConnectAddsUserToConnectionDetail() { | |
LocalNimbusDeployment localNimbusDeployment = LocalNimbusDeployment.getNewInstance("com.nimbusframework.examples.webchat"); | |
Map<String, String> queryStringParams = new HashMap<>(); | |
queryStringParams.put("user", "user1"); | |
Map<String, String> headers = new HashMap<>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@FileStorageBucket( | |
bucketName = Website.WEBSITE_BUCKET, | |
staticWebsite = true, | |
indexFile = "webchat.html", | |
stages = {DEV_STAGE, PRODUCTION_STAGE} | |
) | |
@FileUpload(bucketName = Website.WEBSITE_BUCKET, | |
localPath = "src/website", | |
targetPath = "", | |
substituteNimbusVariables = true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
connected = document.getElementById("connected"); | |
recipient = document.getElementById("recipient"); | |
log = document.getElementById("log"); | |
chat = document.getElementById("chat"); | |
username = document.getElementById("username"); | |
form = chat.form; | |
state = document.getElementById("status"); | |
if (window.WebSocket === undefined) { | |
state.innerHTML = "sockets not supported"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WebchatRestApi { | |
private DocumentStoreClient<UserDetail> userDetails = ClientBuilder.getDocumentStoreClient(UserDetail.class); | |
private KeyValueStoreClient<String, ConnectionDetail> connectionDetails = ClientBuilder.getKeyValueStoreClient(String.class, ConnectionDetail.class); | |
@HttpServerlessFunction(method = HttpMethod.POST, path = "register", stages = {DEV_STAGE, PRODUCTION_STAGE}, allowedCorsOrigin = "${WEBCHATNIMBUS_URL}") | |
@UsesDocumentStore(dataModel = UserDetail.class, stages = {DEV_STAGE, PRODUCTION_STAGE}) | |
public void register(String username) { | |
userDetails.put(new UserDetail(username, null)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WebchatApi { | |
private ServerlessFunctionWebSocketClient webSocketClient = ClientBuilder.getServerlessFunctionWebSocketClient(); | |
private DocumentStoreClient<UserDetail> userDetails = ClientBuilder.getDocumentStoreClient(UserDetail.class); | |
private KeyValueStoreClient<String, ConnectionDetail> connectionDetails = ClientBuilder.getKeyValueStoreClient(String.class, ConnectionDetail.class); | |
@WebSocketServerlessFunction(topic = "$connect", stages = {DEV_STAGE, PRODUCTION_STAGE}) | |
@UsesDocumentStore(dataModel = UserDetail.class, stages = {DEV_STAGE, PRODUCTION_STAGE}) | |
@UsesKeyValueStore(dataModel = ConnectionDetail.class, stages = {DEV_STAGE, PRODUCTION_STAGE}) | |
public void onConnect(WebSocketEvent event) throws Exception { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Message { | |
private String message; | |
private String sender; | |
public Message() {} | |
public Message(String message, String sender) { | |
this.message = message; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WebSocketMessage { | |
public WebSocketMessage() {} | |
private String message = ""; | |
private String recipient = ""; | |
public String getMessage() { | |
return message; |
NewerOlder