Class: Proctoring::VideoStreamingsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/proctoring/video_streamings_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_api_token, #authenticate_app_token

Instance Method Details

#createObject

POST /video_streamings



26
27
28
29
30
31
32
33
34
# File 'app/controllers/proctoring/video_streamings_controller.rb', line 26

def create
  @video_streaming = VideoStreaming.new(video_streaming_params)

  if @video_streaming.save
    redirect_to @video_streaming, notice: 'Video streaming was successfully created.'
  else
    render :new
  end
end

#destroyObject

DELETE /video_streamings/1



59
60
61
62
# File 'app/controllers/proctoring/video_streamings_controller.rb', line 59

def destroy
  @video_streaming.stopped!
  redirect_to video_streamings_url, notice: 'Video streaming was successfully destroyed.'
end

#distribute_channel_to_roomsObject



86
87
88
89
90
91
# File 'app/controllers/proctoring/video_streamings_controller.rb', line 86

def distribute_channel_to_rooms
  @no_of_users_in_channel = proctor_user_params[:no_of_users_in_channel].to_i
  @event_id = proctor_user_params[:event_id]
  VideoStreaming.setup_rooms(@event_id, @no_of_users_in_channel)
  @all_rooms = VideoStreamingRoom.where(event_id: @event_id, total_users: @no_of_users_in_channel).active
end

#editObject

GET /video_streamings/1/edit



22
23
# File 'app/controllers/proctoring/video_streamings_controller.rb', line 22

def edit
end

#eventObject



64
65
66
# File 'app/controllers/proctoring/video_streamings_controller.rb', line 64

def event
  @video_streamings = VideoStreaming.by_event(params[:id])
end

#indexObject

GET /video_streamings



8
9
10
# File 'app/controllers/proctoring/video_streamings_controller.rb', line 8

def index
  @video_streamings = VideoStreaming.where(status: :active).limit(15)
end

#newObject

GET /video_streamings/new



17
18
19
# File 'app/controllers/proctoring/video_streamings_controller.rb', line 17

def new
  @video_streaming = VideoStreaming.new
end

#showObject

GET /video_streamings/1



13
14
# File 'app/controllers/proctoring/video_streamings_controller.rb', line 13

def show
end

#stream_channelObject



75
76
77
78
79
# File 'app/controllers/proctoring/video_streamings_controller.rb', line 75

def stream_channel
  @media_server_url = Proctoring.media_server_url
  @video_streaming = VideoStreaming.find_by(channel: params[:id])
  @channels = [@video_streaming.channel]
end

#stream_roomObject



81
82
83
84
# File 'app/controllers/proctoring/video_streamings_controller.rb', line 81

def stream_room
  @media_server_url = Proctoring.media_server_url
  @video_streaming_room = VideoStreamingRoom.find_by(room: params[:id])
end

#updateObject

PATCH/PUT /video_streamings/1



37
38
39
40
41
42
43
# File 'app/controllers/proctoring/video_streamings_controller.rb', line 37

def update
  if @video_streaming.update(video_streaming_params)
    redirect_to @video_streaming, notice: 'Video streaming was successfully updated.'
  else
    render :edit
  end
end

#upload_videoObject

PATCH/PUT /video_streamings/1/upload_video



46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/proctoring/video_streamings_controller.rb', line 46

def upload_video
  video_streaming = video_streaming_params
  # return unless session[:user_id] != video_streaming[:user_id]
  # video_streaming[:videos] = @video_streaming.all_attached_videos_sign_ids + video_streaming[:videos]
  # p video_streaming
  if @video_streaming.update(video_streaming_params)
    render json: {}, status: :ok
  else
    render json: {}, status: 422
  end
end

#user_channelObject



68
69
70
71
72
73
# File 'app/controllers/proctoring/video_streamings_controller.rb', line 68

def user_channel
  user_id = params[:user_id]
  event_id = params[:event_id]
  video_streaming = VideoStreaming.open_join_channel(user_id, event_id)
  render json: { id: video_streaming.id, channel: video_streaming.channel, socketURL: Proctoring.media_server_url }
end