diff --git a/app/assets/javascripts/controllers/room_controller.js b/app/assets/javascripts/controllers/video_room_controller.js similarity index 90% rename from app/assets/javascripts/controllers/room_controller.js rename to app/assets/javascripts/controllers/video_room_controller.js index e54d9e45..2077f057 100644 --- a/app/assets/javascripts/controllers/room_controller.js +++ b/app/assets/javascripts/controllers/video_room_controller.js @@ -1,15 +1,15 @@ import { Controller } from '@hotwired/stimulus' import Client from 'models/client' import WebrtcNegotiation from 'models/webrtc_negotiation' -import RoomSubscription from 'subscriptions/room_subscription' +import VideoRoomSubscription from 'subscriptions/video_room_subscription' import Signaller from 'subscriptions/signaling_subscription' -export default class RoomController extends Controller { +export default class VideoRoomController extends Controller { connect() { this.clients = {} this.client = new Client(this.clientIdValue) - this.subscription = new RoomSubscription({ + this.subscription = new VideoRoomSubscription({ delegate: this, id: this.idValue, clientId: this.client.id @@ -120,9 +120,9 @@ export default class RoomController extends Controller { return this.clients[id].negotiation } - // RoomSubscription Delegate + // VideoRoomSubscription Delegate - roomPinged (data) { + videoRoomPinged (data) { this.greetNewClient(data) } @@ -143,5 +143,5 @@ export default class RoomController extends Controller { } } -RoomController.values = { id: String, clientId: String } -RoomController.targets = ['localMedium', 'remoteMedium', 'enter'] +VideoRoomController.values = { id: String, clientId: String } +VideoRoomController.targets = ['localMedium', 'remoteMedium', 'enter'] diff --git a/app/assets/javascripts/subscriptions/room_subscription.js b/app/assets/javascripts/subscriptions/video_room_subscription.js similarity index 80% rename from app/assets/javascripts/subscriptions/room_subscription.js rename to app/assets/javascripts/subscriptions/video_room_subscription.js index edea32c9..6b81cc00 100644 --- a/app/assets/javascripts/subscriptions/room_subscription.js +++ b/app/assets/javascripts/subscriptions/video_room_subscription.js @@ -1,6 +1,6 @@ import { cable } from '@hotwired/turbo-rails' -export default class RoomSubscription { +export default class VideoRoomSubscription { constructor ({ delegate, id, clientId }) { this.delegate = delegate this.id = id @@ -11,7 +11,7 @@ export default class RoomSubscription { const self = this this.subscription = await cable.subscribeTo({ - channel: 'RoomChannel', + channel: 'VideoRoomChannel', id: this.id, client_id: this.clientId }, { @@ -23,8 +23,7 @@ export default class RoomSubscription { // Ignore self-sent data if (data.from === self.clientId) return - if (data.type === 'ping') self.delegate.roomPinged(data) - } + if (data.type === 'ping') self.delegate.videoRoomPinged(data) } }) this.started = true diff --git a/app/channels/signaling_channel.rb b/app/channels/signaling_channel.rb index fb7b66ed..1aaf8384 100644 --- a/app/channels/signaling_channel.rb +++ b/app/channels/signaling_channel.rb @@ -1,9 +1,9 @@ class SignalingChannel < ApplicationCable::Channel def subscribed - stream_for Room.new(id: params[:id]) + stream_for VideoRoom.new(id: params[:id]) end def signal(data) - broadcast_to(Room.new(id: params[:id]), data) + broadcast_to(VideoRoom.new(id: params[:id]), data) end end diff --git a/app/channels/room_channel.rb b/app/channels/video_room_channel.rb similarity index 57% rename from app/channels/room_channel.rb rename to app/channels/video_room_channel.rb index df0a113b..e271cb23 100644 --- a/app/channels/room_channel.rb +++ b/app/channels/video_room_channel.rb @@ -1,13 +1,13 @@ -class RoomChannel < ApplicationCable::Channel +class VideoRoomChannel < ApplicationCable::Channel def subscribed - @room = find_room - stream_for @room - broadcast_to @room, { type: 'ping', from: params[:client_id] } + @video_room = find_video_room + stream_for @video_room + broadcast_to @video_room, { type: 'ping', from: params[:client_id] } end def unsubscribed Turbo::StreamsChannel.broadcast_remove_to( - find_room, + find_video_room, target: "medium_#{current_client.id}" ) end @@ -23,7 +23,7 @@ class RoomChannel < ApplicationCable::Channel private - def find_room - Room.new(id: params[:id]) + def find_video_room + VideoRoom.new(id: params[:id]) end end diff --git a/app/controllers/rooms_controller.rb b/app/controllers/video_rooms_controller.rb similarity index 70% rename from app/controllers/rooms_controller.rb rename to app/controllers/video_rooms_controller.rb index 411bddab..6471be40 100644 --- a/app/controllers/rooms_controller.rb +++ b/app/controllers/video_rooms_controller.rb @@ -1,4 +1,4 @@ -class RoomsController < ApplicationController +class VideoRoomsController < ApplicationController before_action :skip_authorization def new @@ -11,6 +11,6 @@ class RoomsController < ApplicationController def show @client = Client.new(id: SecureRandom.uuid) cookies.encrypted[:client_id] = @client.id - @room = Room.new(id: params[:id]) + @video_room = VideoRoom.new(id: params[:id]) end end diff --git a/app/javascript/controllers/room_controller.js b/app/javascript/controllers/video_room_controller.js similarity index 90% rename from app/javascript/controllers/room_controller.js rename to app/javascript/controllers/video_room_controller.js index e54d9e45..2077f057 100644 --- a/app/javascript/controllers/room_controller.js +++ b/app/javascript/controllers/video_room_controller.js @@ -1,15 +1,15 @@ import { Controller } from '@hotwired/stimulus' import Client from 'models/client' import WebrtcNegotiation from 'models/webrtc_negotiation' -import RoomSubscription from 'subscriptions/room_subscription' +import VideoRoomSubscription from 'subscriptions/video_room_subscription' import Signaller from 'subscriptions/signaling_subscription' -export default class RoomController extends Controller { +export default class VideoRoomController extends Controller { connect() { this.clients = {} this.client = new Client(this.clientIdValue) - this.subscription = new RoomSubscription({ + this.subscription = new VideoRoomSubscription({ delegate: this, id: this.idValue, clientId: this.client.id @@ -120,9 +120,9 @@ export default class RoomController extends Controller { return this.clients[id].negotiation } - // RoomSubscription Delegate + // VideoRoomSubscription Delegate - roomPinged (data) { + videoRoomPinged (data) { this.greetNewClient(data) } @@ -143,5 +143,5 @@ export default class RoomController extends Controller { } } -RoomController.values = { id: String, clientId: String } -RoomController.targets = ['localMedium', 'remoteMedium', 'enter'] +VideoRoomController.values = { id: String, clientId: String } +VideoRoomController.targets = ['localMedium', 'remoteMedium', 'enter'] diff --git a/app/javascript/subscriptions/room_subscription.js b/app/javascript/subscriptions/video_room_subscription.js similarity index 80% rename from app/javascript/subscriptions/room_subscription.js rename to app/javascript/subscriptions/video_room_subscription.js index edea32c9..fd4aadc7 100644 --- a/app/javascript/subscriptions/room_subscription.js +++ b/app/javascript/subscriptions/video_room_subscription.js @@ -1,6 +1,6 @@ import { cable } from '@hotwired/turbo-rails' -export default class RoomSubscription { +export default class VideoRoomSubscription { constructor ({ delegate, id, clientId }) { this.delegate = delegate this.id = id @@ -11,7 +11,7 @@ export default class RoomSubscription { const self = this this.subscription = await cable.subscribeTo({ - channel: 'RoomChannel', + channel: 'VideoRoomChannel', id: this.id, client_id: this.clientId }, { @@ -23,7 +23,7 @@ export default class RoomSubscription { // Ignore self-sent data if (data.from === self.clientId) return - if (data.type === 'ping') self.delegate.roomPinged(data) + if (data.type === 'ping') self.delegate.videoRoomPinged(data) } }) diff --git a/app/models/room.rb b/app/models/video_room.rb similarity index 85% rename from app/models/room.rb rename to app/models/video_room.rb index ef7fbf5e..f64a8f72 100644 --- a/app/models/room.rb +++ b/app/models/video_room.rb @@ -1,4 +1,4 @@ -class Room +class VideoRoom attr_reader :id def initialize(id:) diff --git a/app/views/media/_medium.html.erb b/app/views/media/_medium.html.erb index c96b44cd..e8e0c894 100644 --- a/app/views/media/_medium.html.erb +++ b/app/views/media/_medium.html.erb @@ -2,7 +2,7 @@ class="medium" id="medium_<%= client_id %>" data-controller="medium" - data-room-target="remoteMedium" + data-video-room-target="remoteMedium" > diff --git a/app/views/rooms/show.html.erb b/app/views/rooms/show.html.erb deleted file mode 100644 index 63d75317..00000000 --- a/app/views/rooms/show.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -<%= turbo_stream_from @room %> -<%= turbo_stream_from @client.id %> - -
-
-
- - -
- <%= button_tag 'Enter', data: { room_target: 'enter', action: 'room#enter' } %> -
-
-
-
diff --git a/app/views/rooms/new.html.erb b/app/views/video_rooms/new.html.erb similarity index 56% rename from app/views/rooms/new.html.erb rename to app/views/video_rooms/new.html.erb index 1bc0c16e..94cc7564 100644 --- a/app/views/rooms/new.html.erb +++ b/app/views/video_rooms/new.html.erb @@ -1,3 +1,3 @@ <%= form_with url: rooms_path do |form| %> - <%= form.submit 'Create Room' %> + <%= form.submit 'Create VideoRoom' %> <% end %> diff --git a/app/views/video_rooms/show.html.erb b/app/views/video_rooms/show.html.erb new file mode 100644 index 00000000..6efa7a0d --- /dev/null +++ b/app/views/video_rooms/show.html.erb @@ -0,0 +1,19 @@ +<%= turbo_stream_from @video_room %> +<%= turbo_stream_from @client.id %> + +
+
+
+ + +
+ <%= button_tag 'Enter', data: { video_room_target: 'enter', action: 'video_room#enter' } %> +
+
+
+
diff --git a/config/routes.rb b/config/routes.rb index 56397c08..f3a04027 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -83,7 +83,7 @@ Rails.application.routes.draw do get '/wallet', to: 'visitors#wallet' resources :calls, only: :create mount ActionCable.server, at: '/cable' - resources :rooms, only: [:new, :create, :show] + resources :video_rooms, only: [:new, :create, :show] resources :users do member do get :following