Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Change SDK namespace to Fishjam, update Fishjam to 0.6.1 #5

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "protos"]
path = protos
url = https://github.com/jellyfish-dev/protos.git
url = https://github.com/fishjam-dev/protos.git
2 changes: 1 addition & 1 deletion codegen/openapi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ echo "Generating code for $1...\n"

cd $ROOTDIR \
&& npx openapi-generator-cli generate \
-i https://raw.githubusercontent.com/jellyfish-dev/jellyfish/$1/openapi.yaml \
-i https://raw.githubusercontent.com/fishjam-dev/fishjam/$1/openapi.yaml \
-g typescript-axios \
-o src/openapi
2 changes: 1 addition & 1 deletion codegen/protobuf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ git submodule sync --recursive >> /dev/null
git submodule update --recursive --remote --init >> /dev/null
printf "DONE\n"

file="./protos/jellyfish/server_notifications.proto"
file="./protos/fishjam/server_notifications.proto"

printf "Compiling file $file... "
protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./src/ $file
Expand Down
4 changes: 2 additions & 2 deletions examples/room-manager/.env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PORT=8080
WEBHOOK_URL=http://host.docker.internal:8080/webhook
JELLYFISH_URL=http://localhost:5002
JELLYFISH_SERVER_TOKEN=development
FISHJAM_URL=http://localhost:5002
FISHJAM_SERVER_TOKEN=development
# # Optional configuration:
# ENABLE_SIMULCAST=true
# PEERLESS_PURGE_TIMEOUT=60
Expand Down
2 changes: 1 addition & 1 deletion examples/room-manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A simple web server that uses the SDK to manage rooms and users on a Fishjam ser
To start the Fishjam server and the Room Manager, run the following commands:

```sh
EXTERNAL_IP=`ifconfig | grep 192.168 | cut -d ' ' -f 2` JELLYFISH_VERSION=edge docker compose up
EXTERNAL_IP=`ifconfig | grep 192.168 | cut -d ' ' -f 2` FISHJAM_VERSION=edge docker compose up
cp .env.example .env
npm install
npm start
Expand Down
22 changes: 11 additions & 11 deletions examples/room-manager/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
jellyfish:
image: 'ghcr.io/jellyfish-dev/jellyfish:${JELLYFISH_VERSION:-edge}'
container_name: jellyfish
fishjam:
image: 'ghcr.io/fishjam-dev/fishjam:${FISHJAM_VERSION:-edge}'
container_name: fishjam
restart: on-failure
healthcheck:
test: >
Expand All @@ -10,14 +10,14 @@ services:
retries: 2
timeout: 2s
environment:
JF_PORT: 5002
JF_HOST: 'localhost:5002'
JF_WEBRTC_TURN_IP: '${EXTERNAL_IP:-127.0.0.1}'
JF_WEBRTC_TURN_LISTEN_IP: '0.0.0.0'
JF_WEBRTC_TURN_PORT_RANGE: '50000-50050'
JF_WEBRTC_TURN_TCP_PORT: '49999'
JF_SERVER_API_TOKEN: 'development'
JF_CHECK_ORIGIN: 'false'
FJ_PORT: 5002
FJ_HOST: 'localhost:5002'
FJ_WEBRTC_TURN_IP: '${EXTERNAL_IP:-127.0.0.1}'
FJ_WEBRTC_TURN_LISTEN_IP: '0.0.0.0'
FJ_WEBRTC_TURN_PORT_RANGE: '50000-50050'
FJ_WEBRTC_TURN_TCP_PORT: '49999'
FJ_SERVER_API_TOKEN: 'development'
FJ_CHECK_ORIGIN: 'false'
ports:
- '5002:5002'
- '49999:49999'
Expand Down
16 changes: 8 additions & 8 deletions examples/room-manager/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions examples/room-manager/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "@jellyfish-dev/room-manager",
"name": "@fishjam-dev/room-manager",
"version": "0.1.0",
"description": "A room manager for Jellyfish",
"homepage": "https://github.com/jellyfish-dev/js-server-sdk/examples/room-manager",
"description": "A room manager for Fishjam",
"homepage": "https://github.com/fishjam-dev/js-server-sdk/examples/room-manager",
"repository": {
"type": "git",
"url": "https://github.com/jellyfish-dev/js-server-sdk.git"
"url": "https://github.com/fishjam-dev/js-server-sdk.git"
},
"license": "Apache-2.0",
"keywords": [
"webrtc",
"jellyfish",
"fishjam",
"membrane"
],
"main": "./dist/index.js",
Expand All @@ -28,7 +28,7 @@
"lint:check": "eslint src"
},
"dependencies": {
"@jellyfish-dev/js-server-sdk": "file:../../",
"@fishjam-dev/js-server-sdk": "file:../../",
"axios": "^1.6.8",
"body-parser": "^1.20.2",
"dotenv": "^16.4.5",
Expand Down
4 changes: 2 additions & 2 deletions examples/room-manager/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'dotenv/config';
export default {
port: parseInt(process.env.PORT!),
webhookUrl: process.env.WEBHOOK_URL!,
jellyfishUrl: process.env.JELLYFISH_URL!,
serverToken: process.env.JELLYFISH_SERVER_TOKEN!,
fishjamUrl: process.env.FISHJAM_URL!,
serverToken: process.env.FISHJAM_SERVER_TOKEN!,
enableSimulcast: process.env.ENABLE_SIMULCAST ? process.env.ENABLE_SIMULCAST === 'true' : true,
maxPeers: process.env.MAX_PEERS ? parseInt(process.env.MAX_PEERS) : undefined,
peerlessPurgeTimeout: process.env.PEERLESS_PURGE_TIMEOUT ? parseInt(process.env.PEERLESS_PURGE_TIMEOUT) : undefined,
Expand Down
4 changes: 2 additions & 2 deletions examples/room-manager/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import express, { type RequestHandler } from 'express';
import bodyParser from 'body-parser';

import { ServerMessage } from '@jellyfish-dev/js-server-sdk/proto';
import { ServerMessage } from '@fishjam-dev/js-server-sdk/proto';

import config from './config';
import { RoomService } from './room_service';
Expand All @@ -23,7 +23,7 @@ app.post('/webhook', bodyParser.raw({ type: 'application/x-protobuf' }), (req, r
if (contentType === 'application/x-protobuf' && Buffer.isBuffer(req.body)) {
const message = ServerMessage.decode(req.body);

roomService.handleJellyfishMessage(message);
roomService.handleFishjamMessage(message);

res.status(200).send();
} else {
Expand Down
24 changes: 12 additions & 12 deletions examples/room-manager/src/room_service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import axios from 'axios';

import { type Room as RemoteRoom, type Peer as RemoteUser, RoomApi } from '@jellyfish-dev/js-server-sdk';
import { type Room as RemoteRoom, type Peer as RemoteUser, RoomApi } from '@fishjam-dev/js-server-sdk';

import type {
ServerMessage,
ServerMessage_PeerCrashed,
ServerMessage_PeerDeleted,
ServerMessage_RoomCrashed,
ServerMessage_RoomDeleted,
} from '@jellyfish-dev/js-server-sdk/proto';
} from '@fishjam-dev/js-server-sdk/proto';

import config from './config';

Expand Down Expand Up @@ -39,15 +39,15 @@ export class RoomService {
},
});

this.roomApi = new RoomApi(undefined, config.jellyfishUrl, client);
this.tls = config.jellyfishUrl.startsWith('https');
this.roomApi = new RoomApi(undefined, config.fishjamUrl, client);
this.tls = config.fishjamUrl.startsWith('https');
}

async findOrCreateUser(roomId: string, userId: string): Promise<User> {
const room = await this.findOrCreateRoom(roomId);
let user = room.users.get(userId);

// make sure the user exists on the Jellyfish server as well
// make sure the user exists on the Fishjam server as well
const remoteUser = user ? await this.findRemoteUser(roomId, user.peerId) : null;

if (user && remoteUser) {
Expand All @@ -63,7 +63,7 @@ export class RoomService {
return user;
}

handleJellyfishMessage(notification: ServerMessage): void {
handleFishjamMessage(notification: ServerMessage): void {
Object.entries(notification)
.filter(([_key, value]) => value)
.forEach(([key, value]) => {
Expand Down Expand Up @@ -91,7 +91,7 @@ export class RoomService {
const remoteRoom = await this.findRemoteRoom(roomId);

if (!(room && remoteRoom)) {
await this.findOrCreateRoomInJellyfish(roomId);
await this.findOrCreateRoomInFishjam(roomId);

room = { roomId, users: new Map() };

Expand All @@ -106,7 +106,7 @@ export class RoomService {
data: { data },
} = await this.roomApi.addPeer(roomId, { type: 'webrtc', options: { enableSimulcast: config.enableSimulcast } });

const peerWebsocketUrl = data.peer_websocket_url ?? config.jellyfishUrl + '/socket/peer/websocket';
const peerWebsocketUrl = data.peer_websocket_url ?? config.fishjamUrl + '/socket/peer/websocket';

const peerId = data.peer.id;

Expand All @@ -121,20 +121,20 @@ export class RoomService {
return user;
}

private async findOrCreateRoomInJellyfish(roomId: string): Promise<void> {
private async findOrCreateRoomInFishjam(roomId: string): Promise<void> {
try {
// Check if the room exists in the application.
// This may happen when someone creates a room outside of this application
// or when the room was created in the previous run of the application.
const room = (await this.roomApi.getAllRooms()).data.data.find((room) => room.id === roomId);

if (room) {
console.warn({ message: 'Room already exists in Jellyfish', roomId });
console.warn({ message: 'Room already exists in Fishjam', roomId });

return;
}

console.log({ message: 'Creating a room in Jellyfish', roomId });
console.log({ message: 'Creating a room in Fishjam', roomId });

const optionalConfig = {
maxPeers: config.maxPeers,
Expand All @@ -151,7 +151,7 @@ export class RoomService {
} catch (error) {
const stringified = JSON.stringify(error);

console.error({ message: `Failed to create room in Jellyfish due to ${stringified}`, roomId });
console.error({ message: `Failed to create room in Fishjam due to ${stringified}`, roomId });

throw error;
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "@jellyfish-dev/js-server-sdk",
"name": "@fishjam-dev/js-server-sdk",
"version": "0.1.0",
"description": "Jellyfish server SDK for JavaScript",
"homepage": "https://github.com/jellyfish-dev/js-server-sdk",
"description": "Fishjam server SDK for JavaScript",
"homepage": "https://github.com/fishjam-dev/js-server-sdk",
"repository": {
"type": "git",
"url": "https://github.com/jellyfish-dev/js-server-sdk.git"
"url": "https://github.com/fishjam-dev/js-server-sdk.git"
},
"bugs": {
"url": "https://github.com/jellyfish-dev/js-server-sdk/issues"
"url": "https://github.com/fishjam-dev/js-server-sdk/issues"
},
"license": "Apache-2.0",
"keywords": [
"webrtc",
"jellyfish",
"fishjam",
"server",
"membrane"
],
Expand All @@ -24,14 +24,14 @@
],
"exports": {
".": "./dist/index.js",
"./proto": "./dist/protos/jellyfish/index.js"
"./proto": "./dist/protos/fishjam/index.js"
},
"scripts": {
"build": "tsc",
"build:check": "tsc --noEmit",
"format": "prettier --write .",
"format:check": "prettier --check .",
"docs": "typedoc src src/protos/jellyfish",
"docs": "typedoc src src/protos/fishjam",
"gen:proto": "sh codegen/protobuf.sh",
"gen:api": "sh codegen/openapi.sh",
"prepare": "tsc"
Expand Down
2 changes: 1 addition & 1 deletion protos
1 change: 1 addition & 0 deletions src/openapi/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.gitignore
.npmignore
.openapi-generator-ignore
api.ts
base.ts
common.ts
Expand Down
Loading