diff --git a/basic/backend/java/README.md b/basic/backend/java/README.md index c9854032..b576e0b2 100644 --- a/basic/backend/java/README.md +++ b/basic/backend/java/README.md @@ -1,6 +1,6 @@ # Basic Backend Java -Basic server application built with Spring Boot and Java. It internally uses [livekit-server-sdk-kotlin](https://github.com/livekit/server-sdk-kotlin). +Basic server application built for Java with Spring Boot. It internally uses [livekit-server-sdk-kotlin](https://github.com/livekit/server-sdk-kotlin). For further information, check the [tutorial documentation](https://livekit-tutorials.openvidu.io/basic/backend/java). diff --git a/basic/backend/java/pom.xml b/basic/backend/java/pom.xml index dabe9e71..246e8e84 100644 --- a/basic/backend/java/pom.xml +++ b/basic/backend/java/pom.xml @@ -14,7 +14,7 @@ basic-java 0.0.1-SNAPSHOT basic-java - Basic server application built with Spring Boot and Java + Basic server application built for Java with Spring Boot 17 diff --git a/basic/backend/node/README.md b/basic/backend/node/README.md index b1480e61..962351d9 100644 --- a/basic/backend/node/README.md +++ b/basic/backend/node/README.md @@ -1,6 +1,6 @@ # Basic Backend Node -Basic server application built with Node.js and Express. It internally uses [livekit-server-sdk-js](https://docs.livekit.io/server-sdk-js/). +Basic server application built for Node.js with Express. It internally uses [livekit-server-sdk-js](https://docs.livekit.io/server-sdk-js/). For further information, check the [tutorial documentation](https://livekit-tutorials.openvidu.io/basic/backend/node). diff --git a/basic/backend/node/package.json b/basic/backend/node/package.json index e83c34c0..75fdbb4c 100644 --- a/basic/backend/node/package.json +++ b/basic/backend/node/package.json @@ -1,7 +1,7 @@ { "name": "basic-node", "version": "1.0.0", - "description": "Basic server application built with Node.js and Express", + "description": "Basic server application built for Node.js with Express", "main": "index.js", "type": "module", "scripts": { diff --git a/basic/backend/python/README.md b/basic/backend/python/README.md index 664f4299..48f4cf43 100644 --- a/basic/backend/python/README.md +++ b/basic/backend/python/README.md @@ -1,6 +1,6 @@ # Basic Backend Node -Basic server application built with Python and Flask. It internally uses [livekit-python-sdk](https://github.com/livekit/python-sdks). +Basic server application built for Python with Flask. It internally uses [livekit-python-sdk](https://github.com/livekit/python-sdks). For further information, check the [tutorial documentation](https://livekit-tutorials.openvidu.io/basic/backend/python). diff --git a/basic/backend/ruby/.gitignore b/basic/backend/ruby/.gitignore new file mode 100644 index 00000000..c7ed8e79 --- /dev/null +++ b/basic/backend/ruby/.gitignore @@ -0,0 +1,56 @@ +*.gem +*.rbc +/.config +/coverage/ +/InstalledFiles +/pkg/ +/spec/reports/ +/spec/examples.txt +/test/tmp/ +/test/version_tmp/ +/tmp/ + +# Used by dotenv library to load environment variables. +# .env + +# Ignore Byebug command history file. +.byebug_history + +## Specific to RubyMotion: +.dat* +.repl_history +build/ +*.bridgesupport +build-iPhoneOS/ +build-iPhoneSimulator/ + +## Specific to RubyMotion (use of CocoaPods): +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# vendor/Pods/ + +## Documentation cache and generated files: +/.yardoc/ +/_yardoc/ +/doc/ +/rdoc/ + +## Environment normalization: +/.bundle/ +/vendor/bundle +/lib/bundler/man/ + +# for a library or gem, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +Gemfile.lock +# .ruby-version +# .ruby-gemset + +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: +.rvmrc + +# Used by RuboCop. Remote config files pulled in from inherit_from directive. +# .rubocop-https?--* \ No newline at end of file diff --git a/basic/backend/ruby/Gemfile b/basic/backend/ruby/Gemfile new file mode 100644 index 00000000..bffa57f2 --- /dev/null +++ b/basic/backend/ruby/Gemfile @@ -0,0 +1,6 @@ +source 'https://rubygems.org' + +gem 'sinatra' +gem 'sinatra-cors' +gem 'puma' +gem 'livekit-server-sdk' \ No newline at end of file diff --git a/basic/backend/ruby/README.md b/basic/backend/ruby/README.md new file mode 100644 index 00000000..f605c059 --- /dev/null +++ b/basic/backend/ruby/README.md @@ -0,0 +1,30 @@ +# Basic Backend Node + +Basic server application built for Ruby with Sinatra. It internally uses [livekit-server-sdk-ruby](https://github.com/livekit/server-sdk-ruby). + +For further information, check the [tutorial documentation](https://livekit-tutorials.openvidu.io/basic/backend/ruby). + +## Prerequisites + +- [Ruby](https://www.ruby-lang.org/en/downloads/) + +## Run + +1. Download repository + +```bash +git clone https://github.com/OpenVidu/openvidu-livekit-tutorials.git +cd openvidu-livekit-tutorials/basic/backend/ruby +``` + +2. Install dependencies + +```bash +bundle install +``` + +3. Run the application + +```bash +ruby app.rb +``` diff --git a/basic/backend/ruby/app.rb b/basic/backend/ruby/app.rb new file mode 100644 index 00000000..78850b1a --- /dev/null +++ b/basic/backend/ruby/app.rb @@ -0,0 +1,35 @@ +require 'sinatra' +require 'sinatra/cors' +require 'livekit' +require './env.rb' + +SERVER_PORT = ENV['SERVER_PORT'] || 6080 +LIVEKIT_API_KEY = ENV['LIVEKIT_API_KEY'] || 'devkey' +LIVEKIT_API_SECRET = ENV['LIVEKIT_API_SECRET'] || 'secret' + +set :port, SERVER_PORT + +register Sinatra::Cors +set :allow_origin, "*" +set :allow_methods, "POST,OPTIONS" +set :allow_headers, "content-type" + +post '/token' do + content_type :json + + body = JSON.parse(request.body.read) + room_name = body['roomName'] + participant_name = body['participantName'] + + if room_name.nil? || participant_name.nil? + status 400 + return 'roomName and participantName are required' + end + + token = LiveKit::AccessToken.new(api_key: LIVEKIT_API_KEY, api_secret: LIVEKIT_API_SECRET) + token.identity = participant_name + token.name = participant_name + token.add_grant(roomJoin: true, room: room_name) + + return token.to_jwt +end diff --git a/basic/backend/ruby/env.rb b/basic/backend/ruby/env.rb new file mode 100644 index 00000000..0daa2892 --- /dev/null +++ b/basic/backend/ruby/env.rb @@ -0,0 +1,3 @@ +ENV['SERVER_PORT'] = '6080' +ENV['LIVEKIT_API_KEY'] = 'devkey' +ENV['LIVEKIT_API_SECRET'] = 'secret' \ No newline at end of file