Compare commits

..

5 Commits

Author SHA1 Message Date
qvalentin b01b637a22 Broadcast on disconnect and websocket server fix for docker 2023-04-07 16:22:08 +02:00
qvalentin 30bfc6e763 Join room via sidebar 2023-04-07 16:21:15 +02:00
qvalentin 247b99d571 Add Backend to compose 2023-04-07 16:20:48 +02:00
qvalentin f40582cff1 Frontend deploy 2023-04-07 16:19:34 +02:00
qvalentin f117e4cb65 Backend docker deploy 2023-04-07 16:19:13 +02:00
16 changed files with 166 additions and 43 deletions

1
backend/.gitignore vendored
View File

@ -1,3 +1,4 @@
.stack-work/
*~
dist-newstyle
result

55
backend/converted.nix Normal file
View File

@ -0,0 +1,55 @@
{ mkDerivation
, aeson
, base
, bytestring
, classy-prelude
, http-types
, lib
, lifted-base
, mtl
, text
, uuid
, wai
, warp
, websockets
}:
mkDerivation {
pname = "jitsi-rooms";
version = "0.1.0.0";
src = ./.;
isLibrary = true;
isExecutable = true;
libraryHaskellDepends = [
aeson
base
bytestring
classy-prelude
http-types
lifted-base
mtl
text
uuid
wai
warp
websockets
];
executableHaskellDepends = [
aeson
base
bytestring
classy-prelude
http-types
lifted-base
mtl
text
uuid
wai
warp
websockets
];
homepage = "https://github.com/githubuser/jitsi-rooms#readme";
license = lib.licenses.bsd3;
mainProgram = "jitsi-rooms-exe";
enableSharedExecutables = false;
postFixup = "rm -rf $out/lib $out/nix-support $out/share/doc";
}

34
backend/default.nix Normal file
View File

@ -0,0 +1,34 @@
let
config = {
packageOverrides = pkgs: rec {
haskellPackages = pkgs.haskellPackages.override {
overrides = haskellPackagesNew: haskellPackagesOld: rec {
jitsi-rooms =
haskellPackagesNew.callPackage ./converted.nix { };
};
};
};
};
pkgs = import <nixpkgs> { inherit config; };
in
pkgs.dockerTools.buildImage {
name = "jitsi-rooms";
tag = "latest";
copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [
pkgs.bash
pkgs.coreutils
];
pathsToLink = [ "/bin" ];
};
config = {
Cmd = [ "${pkgs.haskellPackages.jitsi-rooms}/bin/jitsi-rooms-exe" ];
ExposedPorts = {
"9160/tcp" = { };
"8081/tcp" = { };
};
};
}

5
backend/deploy.sh Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
nix-build
scp ./result ffs:/home/ffsys/jitsi-rooms-docker-image

View File

@ -91,28 +91,3 @@ executable jitsi-rooms-exe
, websockets
default-language: Haskell2010
test-suite jitsi-rooms-test
type: exitcode-stdio-1.0
main-is: Spec.hs
other-modules:
Paths_jitsi_rooms
hs-source-dirs:
test
default-extensions:
NoImplicitPrelude,OverloadedStrings,ImportQualifiedPost
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
build-depends:
aeson
, base >=4.7 && <5
, bytestring
, classy-prelude
, http-types
, jitsi-rooms
, lifted-base
, mtl
, text
, uuid
, wai
, warp
, websockets
default-language: Haskell2010

View File

@ -6,6 +6,7 @@ module WebSocket.MonadWebSocketSession
)
where
import BroadcastUserData (MonadBroadcast, broadcastUserData)
import ClassyPrelude
import Data.Aeson
( FromJSON,
@ -16,6 +17,7 @@ import State.ConnectedClientsState
( MonadConnectedClientsModify,
removeWSClient,
)
import State.RoomDataState (MonadRoomDataStateRead)
import Types.ConnectionState (Client (..))
import Types.WebSocketMessages.WebSocketMessages (SetClientInfo (..))
import WebSocket.Messages
@ -56,9 +58,12 @@ newClientGeneric clientInfo = do
disconnectWsClient ::
( MonadConnectedClientsModify m,
MonadRoomDataStateRead m,
MonadBroadcast m,
MonadWebSocketSession m
) =>
m ()
disconnectWsClient = do
clientId <- getSesssionId
removeWSClient clientId
broadcastUserData

View File

@ -18,9 +18,9 @@ runWebSocketServer ::
) =>
m ()
runWebSocketServer = do
putStrLn "Websocket up at 127.0.0.1:9160"
putStrLn "Websocket up at 0.0.0.0:9160"
wsApp' <- runWSApp
liftIO $ WS.runServer "127.0.0.1" 9160 wsApp'
liftIO $ WS.runServer "0.0.0.0" 9160 wsApp'
runWSApp ::
( MonadIO m,

5
frontend/deploy.sh Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env sh
yarn build
scp -r dist/* ffs:/home/ffsys/apps/static/jitsi-rooms

View File

@ -0,0 +1,4 @@
#!/usr/bin/env sh
ssh -L 9160:localhost:9160 ffs

View File

@ -1,28 +1,42 @@
import { useState } from "react";
import "./App.css";
import Meeting from "./components/meeting/Meeting";
import Sidebar from "./components/sidebar/Sidebar";
import useBackendData from "./hooks/useBackendData";
import useConferenceData from "./hooks/useConferenceData";
import useLocalUser from "./hooks/useLocalUser";
import { useRoomName } from "./hooks/useRoomName";
function App() {
const { userInfo, setUserInfo } = useLocalUser();
const { roomName, updateRoomName, updateAndSubmitRoomName, submitRoomName } = useRoomName();
const { roomData, sendMessage } = useBackendData(userInfo);
const { conferenceData, setConferenceData } = useConferenceData(
sendMessage,
setUserInfo
);
const [meetingStarted, setMeetingStarted] = useState(false);
console.log(roomData);
if (roomData && userInfo) {
return (
<div className="App">
<Sidebar usersData={roomData} />
<Sidebar usersData={roomData}
updateAndSubmitRoomName={(roomName: string) => {
updateAndSubmitRoomName(roomName)
setMeetingStarted(true)
}}
/>
<Meeting
conferenceData={conferenceData}
setConferenceData={setConferenceData}
userInfo={userInfo}
roomName={roomName}
updateRoomName={updateRoomName}
submitRoomName={submitRoomName}
meetingStarted={meetingStarted}
setMeetingStarted={setMeetingStarted}
/>
</div>
);

View File

@ -1,7 +1,5 @@
const ISPROD = window.location.protocol == "https:";
const JITSI_DOMAIN = ISPROD
? "thisisnotajitsi.filefighter.de"
: "localhost:8443";
const JITSI_DOMAIN = "thisisnotajitsi.filefighter.de";
const WEBSOCKET_URL =
"ws" +
(ISPROD ? "s" : "") +

View File

@ -9,11 +9,12 @@ interface Props {
conferenceData: ConferenceData | undefined;
setConferenceData: (newData: ConferenceData) => void;
userInfo: UserInfo;
//@ts-ignore
roomName, updateRoomName, submitRoomName
meetingStarted: Boolean, setMeetingStarted: Function
}
function Meeting({ conferenceData, setConferenceData, userInfo }: Props) {
const { roomName, updateRoomName, submitRoomName } = useRoomName();
const [meetingStarted, setMeetingStarted] = useState(false);
function Meeting({ conferenceData, setConferenceData, userInfo, roomName, updateRoomName, submitRoomName, meetingStarted, setMeetingStarted }: Props) {
const startMeeting = useCallback(() => {
submitRoomName();

View File

@ -5,6 +5,7 @@ import { UsersData } from "../../background/types/roomData";
interface Props {
usersData: UsersData;
updateAndSubmitRoomName: Function
}
function Sidebar(props: Props) {
@ -14,17 +15,17 @@ function Sidebar(props: Props) {
return (
<div className={`sidebar sidebar-${sidebarVisibility}`}>
<SidebarHeader sidebarVisibility={sidebarVisibility} />
<div>
<h3> No room</h3>
{props.usersData.usersWithOutRoom.map((username) => (
<div>{username}</div>
))}
</div>
<div>
{props.usersData.roomsData.map((roomData) => {
return (
<>
<h3> {roomData.roomName} </h3>
<h3>
<a href="#" onClick={() => {
props.updateAndSubmitRoomName(roomData.roomName)
}}>
{roomData.roomName}
</a>
</h3>
{roomData.participants.map((participant) => (
<div> {participant.displayName} </div>
))}
@ -32,6 +33,12 @@ function Sidebar(props: Props) {
);
})}
</div>
<div>
<h3> No room</h3>
{props.usersData.usersWithOutRoom.map((username) => (
<div>{username}</div>
))}
</div>
<div className="sidebar-footer">
<button onClick={toggleSidebarVisibility}>{sidebarToggleText}</button>
</div>

View File

@ -11,12 +11,22 @@ function useRoomName() {
[setRoomName]
);
const updateAndSubmitRoomName = useCallback(
(newName: string) => {
setRoomName(newName);
setRoomNameInUrl(newName);
setRoomNameInTitle(newName);
console.log("[Rooms] update and submit room name", newName);
},
[setRoomName]
)
const submitRoomName = useCallback(() => {
setRoomNameInUrl(roomName);
setRoomNameInTitle(roomName);
}, [roomName]);
return { roomName, updateRoomName, submitRoomName };
return { roomName, updateRoomName, updateAndSubmitRoomName, submitRoomName };
}
function getRoomNameFromUrl(): string {

View File

@ -211,7 +211,7 @@ JIBRI_XMPP_PASSWORD=662f13288a07ca64afb4b9b97b4feed6
#
# Container restart policy
#RESTART_POLICY=unless-stopped
RESTART_POLICY=no
# Jitsi image version (useful for local development)
#JITSI_IMAGE_VERSION=latest

View File

@ -346,6 +346,15 @@ services:
networks:
meet.jitsi:
jitsi-rooms:
image: jitsi-rooms:67y5d9y2zbi7wkqm2jpcjj1k2614qwx2
restart: ${RESTART_POLICY:-unless-stopped}
ports:
- '9160:9160'
networks:
meet.jitsi:
# Custom network so all services can communicate using a FQDN
networks:
meet.jitsi: