WebSocket API

This commit is contained in:
2023-03-14 16:22:50 +01:00
parent b6dba62fa4
commit fd828d600e
16 changed files with 910 additions and 3 deletions

View File

@@ -0,0 +1,36 @@
package fr.pandacube.lib.ws.payloads;
/**
* Error message payload.
*/
public class ErrorPayload extends Payload {
/**
* The error message.
*/
public String message;
/**
* The error Throwable, may be null.
*/
public Throwable throwable;
/**
* Initialize an error payload with a message but not throwable.
* @param message the error message.
*/
public ErrorPayload(String message) {
this(message, null);
}
/**
* Initialize an error payload with a message and a throwable.
* @param message the error message.
* @param throwable the error Throwable, may be null.
*/
public ErrorPayload(String message, Throwable throwable) {
this.message = message;
this.throwable = throwable;
}
@SuppressWarnings("unused")
private ErrorPayload() { } // for Json deserialization
}

View File

@@ -0,0 +1,22 @@
package fr.pandacube.lib.ws.payloads;
/**
* Payload used by the client to login to key-protected websocket endpoint.
*/
public class LoginPayload extends Payload {
/**
* The key to use for login.
*/
public String key;
/**
* Create a new LoginPayload with the provided key.
* @param key the key to use for login.
*/
public LoginPayload(String key) {
this.key = key;
}
@SuppressWarnings("unused")
private LoginPayload() { } // for Json deserialization
}

View File

@@ -0,0 +1,7 @@
package fr.pandacube.lib.ws.payloads;
/**
* Payload used by the server in inform the client the login was successfull.
*/
public class LoginSucceedPayload extends Payload {
}

View File

@@ -0,0 +1,22 @@
package fr.pandacube.lib.ws.payloads;
/**
* A general use message Payload.
*/
public class MessagePayload extends Payload {
/**
* The message.
*/
public String message;
/**
* Initialite a new MessagePayload with the provided message.
* @param message the message.
*/
public MessagePayload(String message) {
this.message = message;
}
@SuppressWarnings("unused")
private MessagePayload() { } // for Json deserialization
}

View File

@@ -0,0 +1,8 @@
package fr.pandacube.lib.ws.payloads;
/**
* Superclass of all payload sent through our websockets.
*/
public abstract class Payload {
}