Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
package websocket
import (
"fmt"
participanthandler "legatus-rme/backend/participantHandler"
partydata "legatus-rme/backend/partyData"
serviceportsinformation "legatus-rme/backend/servicePortsInformation"
typedata "legatus-rme/backend/typeData"
"log"
"net/url"
"github.com/gorilla/websocket"
)
func OpenWebsocket(websocketType string, port []int) interface{} {
var sockets []*websocket.Conn
for _, port := range port {
u := url.URL{Scheme: "ws", Host: fmt.Sprintf("localhost:%d", port)}
socket, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
if err != nil {
log.Fatal("Error connecting to websocket:", err)
}
sockets = append(sockets, socket)
}
switch websocketType {
case "servicePortsInformation":
return serviceportsinformation.ServicePortsInformation{Websocket: sockets[0]}
case "typeBaseData":
return typedata.TypeData{Websocket: sockets[0]}
case "partyBaseData":
return partydata.PartyData{Websocket: sockets[0]}
case "participantHandler":
return participanthandler.ParticipantHandler{ParticipantManagement: sockets[0], MariusSocket: sockets[1]}
default:
log.Fatal("Invalid websocket type")
return nil
}
}