Commit b0435eb4 authored by SR-Lut3t1um's avatar SR-Lut3t1um

enhanced database support waiting for quarkus to support gradle

parent 404de836
Pipeline #89232 failed with stages
in 4 minutes and 17 seconds
......@@ -9,6 +9,8 @@ import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
import org.un1qu3.models.User;
import org.un1qu3.resources.AutomatonManager;
@ServerEndpoint("/websocket")
@ApplicationScoped
......@@ -33,12 +35,16 @@ public class AutomatonSocket {
@OnError
public void onError(Session session, Throwable throwable) {
String username = "Hans";
throwable.printStackTrace();
sessions.remove(username);
broadcast("User " + username + " left on error: " + throwable);
}
@OnMessage
public void onMessage(String message) {
public void onMessage(Session session, String message) {
System.out.println("automaton");
AutomatonManager am = new AutomatonManager();
am.createAutomaton("asss", new User("reeee"));
String username = "Hans";
String[] msg = message.split(" ");
if (msg[0].startsWith("automaton")) {
......
......@@ -25,7 +25,7 @@ public class Automaton {
protected Automaton() {
alphabet = new ArrayList<>();
owner = new User("yikes");
owner = null;
}
public Automaton(String name, User owner) {
......
package org.un1qu3.resources;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.transaction.Transactional;
import org.un1qu3.models.Automaton;
import org.un1qu3.models.User;
@ApplicationScoped
public class AutomatonManager {
@Inject EntityManager em;
@Transactional
public void createAutomaton(String name, User user) {
Automaton automaton = new Automaton(name, user);
em.persist(automaton);
}
}
package org.un1qu3.resources;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.transaction.Transactional;
import org.un1qu3.models.User;
@ApplicationScoped
public class UserManager {
@Inject EntityManager em;
@Transactional
public void createUser(String name) {
User user = new User(name);
em.persist(user);
}
}
......@@ -5,5 +5,9 @@ canvas.width = canvas.style.width;
let webSocket = new WebSocket(
'ws://' + window.location.host + "/websocket");
webSocket.onopen = function (event) {
console.log("Socket connected")
};
\ No newline at end of file
console.log("connected")
webSocket.send("automaton new 'cool name'")
};
webSocket.onerror = function (event) {
console.error(event)
}
\ No newline at end of file
# Configuration file
quarkus.datasource.url=jdbc:mariadb://mysql/test
quarkus.datasource.url=jdbc:mariadb://localhost:3306/test
quarkus.datasource.driver=org.mariadb.jdbc.Driver
quarkus.datasource.username=root
quarkus.datasource.password=test123
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment