Remove openvidu-mvc-java and openvidu-mvc-ndoe tutorials

This commit is contained in:
pabloFuente 2022-08-23 16:10:56 +02:00
parent 12c21df5b0
commit 7fc324d144
38 changed files with 0 additions and 31422 deletions

View File

@ -1,24 +0,0 @@
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
target/

View File

@ -1,201 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -1,14 +0,0 @@
[![License badge](https://img.shields.io/badge/license-Apache2-orange.svg)](http://www.apache.org/licenses/LICENSE-2.0)
[![OpenVidu Tests](https://github.com/OpenVidu/openvidu/actions/workflows/openvidu-ce-test.yml/badge.svg)](https://github.com/OpenVidu/openvidu/actions/workflows/openvidu-ce-test.yml)
[![Documentation Status](https://readthedocs.org/projects/openvidu/badge/?version=stable)](https://docs.openvidu.io/en/stable/?badge=stable)
[![Docker badge](https://img.shields.io/docker/pulls/openvidu/openvidu-server-kms.svg)](https://hub.docker.com/r/openvidu/openvidu-server-kms)
[![Support badge](https://img.shields.io/badge/support-sof-yellowgreen.svg)](https://openvidu.discourse.group/)
[![][OpenViduLogo]](http://openvidu.io)
openvidu-mvc-java
===
Visit [docs.openvidu.io/en/stable/tutorials/openvidu-mvc-java/](http://docs.openvidu.io/en/stable/tutorials/openvidu-mvc-java/)
[OpenViduLogo]: https://secure.gravatar.com/avatar/5daba1d43042f2e4e85849733c8e5702?s=120

View File

@ -1,62 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.openvidu</groupId>
<artifactId>openvidu-mvc-java</artifactId>
<version>2.22.0</version>
<packaging>jar</packaging>
<name>openvidu-mvc-java</name>
<url>https://github.com/OpenVidu/openvidu-tutorials/tree/master/openvidu-mvc-java</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<start-class>io.openvidu.mvc.java.App</start-class>
<docker.image.prefix>openvidu</docker.image.prefix>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.openvidu</groupId>
<artifactId>openvidu-java-client</artifactId>
<version>2.22.0</version>
</dependency>
</dependencies>
</project>

View File

@ -1,12 +0,0 @@
package io.openvidu.mvc.java;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}

View File

@ -1,93 +0,0 @@
package io.openvidu.mvc.java;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import io.openvidu.java.client.OpenViduRole;
@Controller
public class LoginController {
public class MyUser {
String name;
String pass;
OpenViduRole role;
public MyUser(String name, String pass, OpenViduRole role) {
this.name = name;
this.pass = pass;
this.role = role;
}
}
public static Map<String, MyUser> users = new ConcurrentHashMap<>();
public LoginController() {
users.put("publisher1", new MyUser("publisher1", "pass", OpenViduRole.PUBLISHER));
users.put("publisher2", new MyUser("publisher2", "pass", OpenViduRole.PUBLISHER));
users.put("subscriber", new MyUser("subscriber", "pass", OpenViduRole.SUBSCRIBER));
}
@RequestMapping(value = "/")
public String logout(HttpSession httpSession) {
if (checkUserLogged(httpSession)) {
return "redirect:/dashboard";
} else {
httpSession.invalidate();
return "index";
}
}
@RequestMapping(value = "/dashboard", method = { RequestMethod.GET, RequestMethod.POST })
public String login(@RequestParam(name = "user", required = false) String user,
@RequestParam(name = "pass", required = false) String pass, Model model, HttpSession httpSession) {
// Check if the user is already logged in
String userName = (String) httpSession.getAttribute("loggedUser");
if (userName != null) {
// User is already logged. Immediately return dashboard
model.addAttribute("username", userName);
return "dashboard";
}
// User wasn't logged and wants to
if (login(user, pass)) { // Correct user-pass
// Validate session and return OK
// Value stored in HttpSession allows us to identify the user in future requests
httpSession.setAttribute("loggedUser", user);
model.addAttribute("username", user);
// Return dashboard.html template
return "dashboard";
} else { // Wrong user-pass
// Invalidate session and redirect to index.html
httpSession.invalidate();
return "redirect:/";
}
}
@RequestMapping(value = "/logout", method = RequestMethod.POST)
public String logout(Model model, HttpSession httpSession) {
httpSession.invalidate();
return "redirect:/";
}
private boolean login(String user, String pass) {
return (user != null && pass != null && users.containsKey(user) && users.get(user).pass.equals(pass));
}
private boolean checkUserLogged(HttpSession httpSession) {
return !(httpSession == null || httpSession.getAttribute("loggedUser") == null);
}
}

View File

@ -1,166 +0,0 @@
package io.openvidu.mvc.java;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import io.openvidu.java.client.ConnectionProperties;
import io.openvidu.java.client.ConnectionType;
import io.openvidu.java.client.OpenVidu;
import io.openvidu.java.client.OpenViduRole;
import io.openvidu.java.client.Session;
@Controller
public class SessionController {
// OpenVidu object as entrypoint of the SDK
private OpenVidu openVidu;
// Collection to pair session names and OpenVidu Session objects
private Map<String, Session> mapSessions = new ConcurrentHashMap<>();
// Collection to pair session names and tokens (the inner Map pairs tokens and
// role associated)
private Map<String, Map<String, OpenViduRole>> mapSessionNamesTokens = new ConcurrentHashMap<>();
// URL where our OpenVidu server is listening
private String OPENVIDU_URL;
// Secret shared with our OpenVidu server
private String SECRET;
public SessionController(@Value("${openvidu.secret}") String secret, @Value("${openvidu.url}") String openviduUrl) {
this.SECRET = secret;
this.OPENVIDU_URL = openviduUrl;
this.openVidu = new OpenVidu(OPENVIDU_URL, SECRET);
}
@RequestMapping(value = "/session", method = RequestMethod.POST)
public String joinSession(@RequestParam(name = "data") String clientData,
@RequestParam(name = "session-name") String sessionName, Model model, HttpSession httpSession) {
try {
checkUserLogged(httpSession);
} catch (Exception e) {
return "index";
}
System.out.println("Getting sessionId and token | {sessionName}={" + sessionName + "}");
// Role associated to this user
OpenViduRole role = LoginController.users.get(httpSession.getAttribute("loggedUser")).role;
// Optional data to be passed to other users when this user connects to the
// video-call. In this case, a JSON with the value we stored in the HttpSession
// object on login
String serverData = "{\"serverData\": \"" + httpSession.getAttribute("loggedUser") + "\"}";
// Build connectionProperties object with the serverData and the role
ConnectionProperties connectionProperties = new ConnectionProperties.Builder().type(ConnectionType.WEBRTC)
.role(role).data(serverData).build();
if (this.mapSessions.get(sessionName) != null) {
// Session already exists
System.out.println("Existing session " + sessionName);
try {
// Generate a new token with the recently created connectionProperties
String token = this.mapSessions.get(sessionName).createConnection(connectionProperties).getToken();
// Update our collection storing the new token
this.mapSessionNamesTokens.get(sessionName).put(token, role);
// Add all the needed attributes to the template
model.addAttribute("sessionName", sessionName);
model.addAttribute("token", token);
model.addAttribute("nickName", clientData);
model.addAttribute("userName", httpSession.getAttribute("loggedUser"));
// Return session.html template
return "session";
} catch (Exception e) {
// If error just return dashboard.html template
model.addAttribute("username", httpSession.getAttribute("loggedUser"));
return "dashboard";
}
} else {
// New session
System.out.println("New session " + sessionName);
try {
// Create a new OpenVidu Session
Session session = this.openVidu.createSession();
// Generate a new token with the recently created connectionProperties
String token = session.createConnection(connectionProperties).getToken();
// Store the session and the token in our collections
this.mapSessions.put(sessionName, session);
this.mapSessionNamesTokens.put(sessionName, new ConcurrentHashMap<>());
this.mapSessionNamesTokens.get(sessionName).put(token, role);
// Add all the needed attributes to the template
model.addAttribute("sessionName", sessionName);
model.addAttribute("token", token);
model.addAttribute("nickName", clientData);
model.addAttribute("userName", httpSession.getAttribute("loggedUser"));
// Return session.html template
return "session";
} catch (Exception e) {
// If error just return dashboard.html template
model.addAttribute("username", httpSession.getAttribute("loggedUser"));
return "dashboard";
}
}
}
@RequestMapping(value = "/leave-session", method = RequestMethod.POST)
public String removeUser(@RequestParam(name = "session-name") String sessionName,
@RequestParam(name = "token") String token, Model model, HttpSession httpSession) throws Exception {
try {
checkUserLogged(httpSession);
} catch (Exception e) {
return "index";
}
System.out.println("Removing user | sessioName=" + sessionName + ", token=" + token);
// If the session exists ("TUTORIAL" in this case)
if (this.mapSessions.get(sessionName) != null && this.mapSessionNamesTokens.get(sessionName) != null) {
// If the token exists
if (this.mapSessionNamesTokens.get(sessionName).remove(token) != null) {
// User left the session
if (this.mapSessionNamesTokens.get(sessionName).isEmpty()) {
// Last user left: session must be removed
this.mapSessions.remove(sessionName);
}
return "redirect:/dashboard";
} else {
// The TOKEN wasn't valid
System.out.println("Problems in the app server: the TOKEN wasn't valid");
return "redirect:/dashboard";
}
} else {
// The SESSION does not exist
System.out.println("Problems in the app server: the SESSION does not exist");
return "redirect:/dashboard";
}
}
private void checkUserLogged(HttpSession httpSession) throws Exception {
if (httpSession == null || httpSession.getAttribute("loggedUser") == null) {
throw new Exception("User not logged");
}
}
}

View File

@ -1,9 +0,0 @@
server.port: 5000
server.ssl.enabled: true
server.ssl.key-store: classpath:openvidu-selfsigned.jks
server.ssl.key-store-password: openvidu
server.ssl.key-store-type: JKS
server.ssl.key-alias: openvidu-selfsigned
openvidu.url: https://localhost:4443/
openvidu.secret: MY_SECRET

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

File diff suppressed because one or more lines are too long

View File

@ -1,377 +0,0 @@
html {
position: relative;
min-height: 100%;
}
nav {
height: 50px;
width: 100%;
z-index: 1;
background-color: #4d4d4d !important;
border-color: #4d4d4d !important;
border-top-right-radius: 0 !important;
border-top-left-radius: 0 !important;
}
.navbar-header {
width: 100%;
}
.nav-icon {
padding: 5px 15px 5px 15px;
float: right;
}
nav a {
color: #ccc !important;
}
nav i.fa {
font-size: 40px;
color: #ccc;
}
nav a:hover {
color: #a9a9a9 !important;
}
nav i.fa:hover {
color: #a9a9a9;
}
#main-container {
padding-bottom: 80px;
}
.vertical-center {
width: -webkit-fit-content;
width: fit-content;
margin: auto;
}
.vertical-center#not-logged form {
width: -moz-fit-content;
margin: auto;
}
.vertical-center#not-logged table {
width: -moz-fit-content;
margin: auto;
}
.vertical-center table {
margin-top: 3em !important;
}
.horizontal-center {
margin: 0 auto;
}
.form-control {
color: #0088aa;
font-weight: bold;
}
.form-control:focus {
border-color: #0088aa;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(0, 136, 170, 0.6);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(0, 136, 170, 0.6);
}
input.btn {
font-weight: bold;
}
.btn {
font-weight: bold !important;
}
.btn-success {
background-color: #06d362 !important;
border-color: #06d362;
}
.btn-success:hover {
background-color: #1abd61 !important;
border-color: #1abd61;
}
.btn-info {
background-color: #0088aa !important;
border-color: #0088aa;
}
.btn-info:hover {
background-color: #00708c !important;
border-color: #00708c;
}
.btn-warning {
background-color: #ffcc00 !important;
border-color: #ffcc00;
color: #4d4d4d;
}
.btn-warning:hover {
background-color: #eabb3a !important;
border-color: #eabb3a;
color: #4d4d4d;
}
.btn-warning:active {
color: #4d4d4d;
}
.btn-warning:focus {
color: #4d4d4d;
}
.btn-warning:active:focus {
color: #4d4d4d;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
background-color: #4d4d4d;
}
.footer .text-muted {
margin: 20px 0;
float: left;
color: #ccc;
}
.openvidu-logo {
height: 35px;
float: right;
margin: 12px 0;
-webkit-transition: all 0.1s ease-in-out;
-moz-transition: all 0.1s ease-in-out;
-o-transition: all 0.1s ease-in-out;
transition: all 0.1s ease-in-out;
}
.openvidu-logo:hover {
-webkit-filter: grayscale(0.5);
filter: grayscale(0.5);
}
.demo-logo {
margin: 0;
height: 22px;
float: left;
padding-right: 8px;
}
a:hover .demo-logo {
-webkit-filter: brightness(0.7);
filter: brightness(0.7);
}
#join {
padding-top: 40px;
}
#not-logged {
padding-top: 40px;
}
#join-dialog h1 {
color: #4d4d4d;
font-weight: bold;
text-align: center;
}
#join-dialog label {
color: #0088aa;
}
#join-dialog input.btn {
margin-top: 15px;
}
#join-dialog hr {
background: #4d4d4d;
}
#img-div {
text-align: center;
padding-bottom: 3em;
}
#img-div img {
height: 15%;
}
#logged {
width: 100%;
}
#join {
max-width: 700px;
margin: auto;
}
#session-header {
margin-bottom: 20px;
}
#session-header form {
display: inline;
}
#session-title {
display: inline-block;
}
#buttonLeaveSession {
float: right;
margin-top: 20px;
}
#video-container video {
position: relative;
float: left;
width: 50%;
cursor: pointer;
}
#video-container div {
float: left;
width: 50%;
position: relative;
margin-left: -50%;
}
#video-container p {
display: inline-block;
background: #f8f8f8;
padding-left: 5px;
padding-right: 5px;
color: #777777;
font-weight: bold;
border-bottom-right-radius: 4px;
}
#video-container p.userName {
float: right;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 0px;
font-weight: lighter;
font-size: 12px;
background: #777777;
color: #f8f8f8;
}
video {
width: 100%;
height: auto;
}
#main-video p {
position: absolute;
display: inline-block;
background: #f8f8f8;
padding-left: 5px;
padding-right: 5px;
font-size: 22px;
color: #777777;
font-weight: bold;
border-bottom-right-radius: 4px;
}
#main-video p.userName {
position: absolute;
right: 0;
font-size: 16px !important;
margin-right: 15px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 0px;
font-weight: lighter;
font-size: 12px;
background: #777777;
color: #f8f8f8;
}
#session img {
width: 100%;
height: auto;
display: inline-block;
object-fit: contain;
vertical-align: baseline;
}
#session #video-container img {
position: relative;
float: left;
width: 50%;
cursor: pointer;
object-fit: cover;
height: 180px;
}
table i {
cursor: pointer;
margin-left: 1em;
}
#tooltip-div {
text-align: left;
}
#tooltip-div hr {
margin: 5px 0;
}
#login-info {
text-align: right;
}
#login-info form {
display: inline;
}
#login-info div {
display: inline;
margin-right: 1em;
}
#name-user {
font-weight: bold;
}
/* xs ans md screen resolutions*/
@media screen and (max-width: 991px) {
#join {
padding-top: inherit;
}
#not-logged {
padding-top: inherit;
}
.container .navbar-header {
margin-right: 0 !important;
margin-left: 0 !important;
}
.nav-icon {
padding: 9px 8px 9px 8px;
}
nav i.fa {
font-size: 32px;
}
.vertical-center {
padding-top: 10px;
}
#img-div {
padding-bottom: 1em;
}
#img-div img {
height: 10%;
}
}

View File

@ -1,82 +0,0 @@
<html>
<head>
<title>openvidu-mvc-java</title>
<meta name="viewport" content="width=device-width, initial-scale=1" charset="utf-8"></meta>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon"></link>
<!-- Bootstrap -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g="
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous"></link>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"></link>
<!-- Bootstrap -->
<link rel="styleSheet" href="style.css" type="text/css" media="screen"></link>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/"><img class="demo-logo" src="images/openvidu_vert_white_bg_trans_cropped.png"/> MVC Java</a>
<a class="navbar-brand nav-icon" href="https://github.com/OpenVidu/openvidu-tutorials/tree/master/openvidu-mvc-java" title="GitHub Repository"
target="_blank"><i class="fa fa-github" aria-hidden="true"></i></a>
<a class="navbar-brand nav-icon" href="http://www.docs.openvidu.io/en/stable/tutorials/openvidu-mvc-java/" title="Documentation" target="_blank"><i class="fa fa-book" aria-hidden="true"></i></a>
</div>
</div>
</nav>
<div id="main-container" class="container">
<div id="logged">
<div id="join" class="vertical-center">
<div id="img-div"><img src="images/openvidu_grey_bg_transp_cropped.png" /></div>
<div id="join-dialog" class="jumbotron">
<h1>Join a video session</h1>
<form class="form-group" action="/session" method="post">
<p>
<label>Participant</label>
<input class="form-control" type="text" name="data" required="true"></input>
</p>
<p>
<label>Session</label>
<input class="form-control" type="text" name="session-name" required="true"></input>
</p>
<p class="text-center">
<button class="btn btn-lg btn-success" type="submit">Join!</button>
</p>
</form>
<hr></hr>
<div id="login-info">
<div>Logged as <span th:text="${username}" id="name-user"></span></div>
<form action="/logout" method="post">
<button id="logout-btn" class="btn btn-warning" type="submit">Log out</button>
</form>
</div>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<div class="text-muted">OpenVidu © 2022</div>
<a href="http://www.openvidu.io/" target="_blank"><img class="openvidu-logo" src="images/openvidu_globe_bg_transp_cropped.png"/></a>
</div>
</footer>
</body>
<script>
window.onload = function () { // Generate participant info
$("input[name='session-name']").val("Session " + Math.floor(Math.random() * 10));
$("input[name='data']").val("Participant " + Math.floor(Math.random() * 100));
}
</script>
</html>

View File

@ -1,93 +0,0 @@
<html>
<head>
<title>openvidu-mvc-java</title>
<meta name="viewport" content="width=device-width, initial-scale=1" charset="utf-8"></meta>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon"></link>
<!-- Bootstrap -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g="
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous"></link>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"></link>
<!-- Bootstrap -->
<link rel="styleSheet" href="style.css" type="text/css" media="screen"></link>
<script>
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip({
html: true
});
});
</script>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/"><img class="demo-logo" src="images/openvidu_vert_white_bg_trans_cropped.png"/> MVC Java</a>
<a class="navbar-brand nav-icon" href="https://github.com/OpenVidu/openvidu-tutorials/tree/master/openvidu-mvc-java" title="GitHub Repository"
target="_blank"><i class="fa fa-github" aria-hidden="true"></i></a>
<a class="navbar-brand nav-icon" href="http://www.docs.openvidu.io/en/stable/tutorials/openvidu-mvc-java/" title="Documentation" target="_blank"><i class="fa fa-book" aria-hidden="true"></i></a>
</div>
</div>
</nav>
<div id="main-container" class="container">
<div id="not-logged" class="vertical-center">
<div id="img-div"><img src="images/openvidu_grey_bg_transp_cropped.png" /></div>
<form class="form-group jumbotron" action="/dashboard" method="post">
<p>
<label>User</label>
<input class="form-control" type="text" name="user" required="true"></input>
</p>
<p>
<label>Pass</label>
<input class="form-control" type="password" name="pass" required="true"></input>
</p>
<p class="text-center">
<button class="btn btn-lg btn-info" type="submit">Log in</button>
</p>
</form>
<table class="table">
<tr>
<th>User</th>
<th>Pass</th>
<th>Role<i data-toggle="tooltip" data-placement="bottom" title="" data-original-title="&lt;div id='tooltip-div'&gt;PUBLISHER&lt;div&gt;Send and receive media&lt;hr&gt;&lt;/div&gt;SUBSCRIBER&lt;div&gt;Receive media&lt;/div&gt;&lt;/div&gt;"
class="glyphicon glyphicon-info-sign"></i></th>
</tr>
<tr>
<td>publisher1</td>
<td>pass</td>
<td>PUBLISHER</td>
</tr>
<tr>
<td>publisher2</td>
<td>pass</td>
<td>PUBLISHER</td>
</tr>
<tr>
<td>subscriber</td>
<td>pass</td>
<td>SUBSCRIBER</td>
</tr>
</table>
</div>
</div>
<footer class="footer">
<div class="container">
<div class="text-muted">OpenVidu © 2022</div>
<a href="http://www.openvidu.io/" target="_blank"><img class="openvidu-logo" src="images/openvidu_globe_bg_transp_cropped.png"/></a>
</div>
</footer>
</body>
</html>

View File

@ -1,254 +0,0 @@
<html>
<head>
<title>openvidu-mvc-java</title>
<meta name="viewport" content="width=device-width, initial-scale=1" charset="utf-8"></meta>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon"></link>
<!-- Bootstrap -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"></link>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"></link>
<!-- Bootstrap -->
<link rel="styleSheet" href="style.css" type="text/css" media="screen"></link>
<script src="openvidu-browser-2.22.0.js"></script>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/">
<img class="demo-logo" src="images/openvidu_vert_white_bg_trans_cropped.png" /> MVC Java</a>
<a class="navbar-brand nav-icon" href="https://github.com/OpenVidu/openvidu-tutorials/tree/master/openvidu-mvc-java" title="GitHub Repository"
target="_blank">
<i class="fa fa-github" aria-hidden="true"></i>
</a>
<a class="navbar-brand nav-icon" href="http://www.docs.openvidu.io/en/stable/tutorials/openvidu-mvc-java/" title="Documentation" target="_blank">
<i class="fa fa-book" aria-hidden="true"></i>
</a>
</div>
</div>
</nav>
<div id="main-container" class="container">
<div id="logged">
<div id="session">
<div id="session-header">
<h1 th:text="${sessionName}" id="session-title"></h1>
<form action="/leave-session" method="post">
<input type="hidden" name="session-name" th:value="${sessionName}"></input>
<input type="hidden" name="token" th:value="${token}"></input>
<button id="buttonLeaveSession" class="btn btn-large btn-danger" type="submit" onclick="leaveSession()">
Leave session</button>
</form>
</div>
<div id="main-video" class="col-md-6">
<p class="nickName"></p>
<p class="userName"></p>
<video autoplay="autoplay" playsinline="true"></video>
</div>
<div id="video-container" class="col-md-6"></div>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<div class="text-muted">OpenVidu © 2022</div>
<a href="http://www.openvidu.io/" target="_blank">
<img class="openvidu-logo" src="images/openvidu_globe_bg_transp_cropped.png" />
</a>
</div>
</footer>
</body>
<script th:inline="javascript">
// Get all the attributes from the template in Thymeleaf style
var sessionName = [[${ sessionName }]];
var token = [[${ token }]];
var nickName = [[${ nickName }]];
var userName = [[${ userName }]];
console.warn('Request of TOKEN gone WELL (TOKEN:' + token + ')');
// --- 1) Get an OpenVidu object ---
OV = new OpenVidu();
// --- 2) Init a session ---
session = OV.initSession();
// --- 3) Specify the actions when events take place in the session ---
// On every new Stream received...
session.on('streamCreated', (event) => {
// Subscribe to the Stream to receive it
// HTML video will be appended to element with 'video-container' id
var subscriber = session.subscribe(event.stream, 'video-container');
// When the HTML video has been appended to DOM...
subscriber.on('videoElementCreated', (event) => {
// Add a new HTML element for the user's name and nickname over its video
appendUserData(event.element, subscriber.stream.connection);
});
});
// On every Stream destroyed...
session.on('streamDestroyed', (event) => {
// Delete the HTML element with the user's name and nickname
removeUserData(event.stream.connection);
});
// On every asynchronous exception...
session.on('exception', (exception) => {
console.warn(exception);
});
// --- 4) Connect to the session passing the retrieved token and some more data from
// the client (in this case a JSON with the nickname chosen by the user) ---
session.connect(token, { clientData: nickName })
.then(() => {
// --- 5) Set page layout for active call ---
$('#session-title').text(sessionName);
$('#join').hide();
$('#session').show();
// Here we check somehow if the user has 'PUBLISHER' role before
// trying to publish its stream. Even if someone modified the client's code and
// published the stream, it wouldn't work if the token sent in Session.connect
// method is not recognized as 'PUBLIHSER' role by OpenVidu Server
if (isPublisher()) {
// --- 6) Get your own camera stream ---
var publisher = OV.initPublisher('video-container', {
audioSource: undefined, // The source of audio. If undefined default microphone
videoSource: undefined, // The source of video. If undefined default webcam
publishAudio: true, // Whether you want to start publishing with your audio unmuted or not
publishVideo: true, // Whether you want to start publishing with your video enabled or not
resolution: '640x480', // The resolution of your video
frameRate: 30, // The frame rate of your video
insertMode: 'APPEND', // How the video is inserted in the target element 'video-container'
mirror: false // Whether to mirror your local video or not
});
// --- 7) Specify the actions when events take place in our publisher ---
// When our HTML video has been added to DOM...
publisher.on('videoElementCreated', (event) => {
// Init the main video with ours and append our data
var userData = {
nickName: nickName,
userName: userName
};
initMainVideo(event.element, userData);
appendUserData(event.element, userData);
$(event.element).prop('muted', true); // Mute local video
});
// --- 8) Publish your stream ---
session.publish(publisher);
} else {
console.warn('You don\'t have permissions to publish');
initMainVideoThumbnail(); // Show SUBSCRIBER message in main video
}
})
.catch(error => {
console.warn('There was an error connecting to the session:', error.code, error.message);
});
function leaveSession() {
// --- 9) Leave the session by calling 'disconnect' method over the Session object ---
session.disconnect();
}
function appendUserData(videoElement, connection) {
var clientData;
var serverData;
var nodeId;
if (connection.nickName) { // Appending local video data
clientData = connection.nickName;
serverData = connection.userName;
nodeId = 'main-videodata';
} else {
clientData = JSON.parse(connection.data.split('%/%')[0]).clientData;
serverData = JSON.parse(connection.data.split('%/%')[1]).serverData;
nodeId = connection.connectionId;
}
var dataNode = document.createElement('div');
dataNode.className = "data-node";
dataNode.id = "data-" + nodeId;
dataNode.innerHTML = '<p class="nickName">' + clientData + '</p><p class="userName">' + serverData + '</p>';
videoElement.parentNode.insertBefore(dataNode, videoElement.nextSibling);
addClickListener(videoElement, clientData, serverData);
}
function removeUserData(connection) {
var userNameRemoved = $("#data-" + connection.connectionId);
if ($(userNameRemoved).find('p.userName').html() === $('#main-video p.userName').html()) {
cleanMainVideo(); // The participant focused in the main video has left
}
$("#data-" + connection.connectionId).remove();
}
function removeAllUserData() {
$(".data-node").remove();
}
function cleanMainVideo() {
$('#main-video video').get(0).srcObject = null;
$('#main-video p').each(function () {
$(this).html('');
});
}
function addClickListener(videoElement, clientData, serverData) {
videoElement.addEventListener('click', function () {
var mainVideo = $('#main-video video').get(0);
if (mainVideo.srcObject !== videoElement.srcObject) {
$('#main-video').fadeOut("fast", () => {
$('#main-video p.nickName').html(clientData);
$('#main-video p.userName').html(serverData);
mainVideo.srcObject = videoElement.srcObject;
$('#main-video').fadeIn("fast");
});
}
});
}
function initMainVideo(videoElement, userData) {
$('#main-video video').get(0).srcObject = videoElement.srcObject;
$('#main-video p.nickName').html(userData.nickName);
$('#main-video p.userName').html(userData.userName);
$('#main-video video').prop('muted', true);
}
function initMainVideoThumbnail() {
$('#main-video video').css("background", "url('images/subscriber-msg.jpg') round");
}
function isPublisher() {
return userName.includes('publisher');
}
</script>
</html>

View File

@ -1,38 +0,0 @@
package io.openvidu.mvc.java.test;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}

View File

@ -1,60 +0,0 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.vscode/

View File

@ -1,201 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -1,14 +0,0 @@
[![License badge](https://img.shields.io/badge/license-Apache2-orange.svg)](http://www.apache.org/licenses/LICENSE-2.0)
[![OpenVidu Tests](https://github.com/OpenVidu/openvidu/actions/workflows/openvidu-ce-test.yml/badge.svg)](https://github.com/OpenVidu/openvidu/actions/workflows/openvidu-ce-test.yml)
[![Documentation Status](https://readthedocs.org/projects/openvidu/badge/?version=stable)](https://docs.openvidu.io/en/stable/?badge=stable)
[![Docker badge](https://img.shields.io/docker/pulls/openvidu/openvidu-server-kms.svg)](https://hub.docker.com/r/openvidu/openvidu-server-kms)
[![Support badge](https://img.shields.io/badge/support-sof-yellowgreen.svg)](https://openvidu.discourse.group/)
[![][OpenViduLogo]](http://openvidu.io)
openvidu-mvc-node
===
Visit [docs.openvidu.io/en/stable/tutorials/openvidu-mvc-node/](http://docs.openvidu.io/en/stable/tutorials/openvidu-mvc-node/)
[OpenViduLogo]: https://secure.gravatar.com/avatar/5daba1d43042f2e4e85849733c8e5702?s=120

View File

@ -1,21 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIDgzCCAmugAwIBAgIJALDBPXTrlAhlMA0GCSqGSIb3DQEBCwUAMFgxCzAJBgNV
BAYTAkVTMRMwEQYDVQQIDApTb21lLVN0YXRlMREwDwYDVQQKDAhPcGVuVmlkdTEh
MB8GCSqGSIb3DQEJARYSb3BlbnZpZHVAZ21haWwuY29tMB4XDTE3MDUzMDE1MjQx
N1oXDTI3MDUyODE1MjQxN1owWDELMAkGA1UEBhMCRVMxEzARBgNVBAgMClNvbWUt
U3RhdGUxETAPBgNVBAoMCE9wZW5WaWR1MSEwHwYJKoZIhvcNAQkBFhJvcGVudmlk
dUBnbWFpbC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDDbK/i
LN80IBnGUbzA4AFl4KQEX6RCreythnfOSnIcQSTP+KjesZMFgsGV0LteDxeCJ+kq
4YoS+CW7ojvOEz3xjCgo4tFdevz8ZoeO0RBQIbARbPako4OXC6vWs6LHwCR0aDWo
9HfS1Uusb8g77csRPRlNA3DGR8dcRTiEBdfHS6Jh/7V7XiDlaxPXj+iIY8PyCqOf
gv4clDt17R+dendDsgYxbmZaodrppNocMQIyUaDIwI4DZOa8nQYk9uuUhkiAFAQB
O642bx6NI0qDu5KgtMmbaS6s+rMnrL8eeZOicqff6XoC6tk6GE8Fo4iYkxp2gAiT
sigaSwpNRWhupISVAgMBAAGjUDBOMB0GA1UdDgQWBBTi3sXqpf42vUNehFU6y4Pn
PTJFRDAfBgNVHSMEGDAWgBTi3sXqpf42vUNehFU6y4PnPTJFRDAMBgNVHRMEBTAD
AQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBfl0C7XAbPdJzCjCsboMTzfC2B4uwspbST
MbUGnmNkTwzeOOsrLQmlCznKGprYV9vGR0MwBzYw2swWCzg/2MLN8swW7NF9gMkK
K61AANxT0qZV/aZhdM7W//pHJoQYsBsQT7cuTrL/VB/niD81uMA/mSWyXIn8KDIy
CPY6jiZ4qiIJnQWhWm1Cazv6O7wjDisvB1cCJhDvBv42KkFwtigt5MQnBEGOI2LD
iKCkXfj33E5B6n0sEel68WgYi6rx2tsR9lzAjCRF+jgNd7FfeUi999m7ykgEACR5
OYRqkVcIXz30r9RxQyFqZLNzyO9oaVZpex8ZbWwEzNXG2ccddnMJ
-----END CERTIFICATE-----

View File

@ -1,27 +0,0 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAw2yv4izfNCAZxlG8wOABZeCkBF+kQq3srYZ3zkpyHEEkz/io
3rGTBYLBldC7Xg8XgifpKuGKEvglu6I7zhM98YwoKOLRXXr8/GaHjtEQUCGwEWz2
pKODlwur1rOix8AkdGg1qPR30tVLrG/IO+3LET0ZTQNwxkfHXEU4hAXXx0uiYf+1
e14g5WsT14/oiGPD8gqjn4L+HJQ7de0fnXp3Q7IGMW5mWqHa6aTaHDECMlGgyMCO
A2TmvJ0GJPbrlIZIgBQEATuuNm8ejSNKg7uSoLTJm2kurPqzJ6y/HnmTonKn3+l6
AurZOhhPBaOImJMadoAIk7IoGksKTUVobqSElQIDAQABAoIBAGr/2HFjFjbpGJOw
b0O/oqRQUh2e7EYiCoOcK37E3iPAO1KvmG6OFayfwjSwG9bNNpbqGU2EPeBTA/3v
PwV/HZxinB5+yhl/3IKp9LDqoR7uwwNXgNf2O3d5SXX91zO9bXhbEn5WlEDYzl00
uxKtCVF//ZlgN+AoruxDbkVDGbkhKHGzvqOW+BWwbYHPOttQ9TQx2ss5+DekpDFV
/FuvXGOcSSV/N+WbDwsqUiM8ovkcflEgQjZYlAY4Ro2U2buf3fKEmy1jxSznNp30
QA4WyYypyS8Hz6S/F4nsjtS3ufCurrWBv4vt2qB+8tH//07NUacjQWZdvEAtaJ+G
IyJgsOUCgYEA38b2SQiw74fwoK6so2XdpCzOObLQBOT1aeZQjt3v8XZ0MPzwWJZm
VkMBmolcEw24xA3jHhOQYafAGjRdaKxlRbJyGJqwENfAs7hO5JSLLWWXsorJQcb7
1OVTFPt7NZopx2Kw7kGGuj9884w57cSl9lsuMptqk8W7pbTo5opOfl8CgYEA35CR
x23kaFDh8+zKUuSdIrkUJ66cazgOfF0FYKiDewd1sGEdZT+gq7Wo8Hi8cp9q+Kuq
MkGrTzu21yMi2fo7RKoSOtV4RQViu6PuoYR/KvRq4F4abHEAivAG4xhPQife84IB
NkDQXaE9EXTP7DXPwj4HV8CnC9LC2qPFU7GVeYsCgYBWPK6c5qSJKrIouif9sDwC
EOJIighwWmvZK9DPvefB/gw49MEK4qr9g0US8Oxyy07w/wkPhiqV97eoYZW9yPIe
Me6WXMaNNxgkKlr86+HW1NfpDmMQ3kYefWHPLDsHJSoElJvqtYXeMKlOkjOg1a+/
iNP83Lftyr3N1jIK5jHpsQKBgE1+clm7qOnT547C7JrxLdrEZs0ehI/R3YuUPvHz
V6gEvPHHqAXZmVsL3CSG5WOiCNVrw9Ip2zTa0RUf08vVJkg1353PMyJRrJi4SVZp
dB8ym/1sASLHxNVkQC7l1UtsQKcN0Fe6/b8GzgFICW6qdHqzP55WZFD/3JUnIZZS
PyrjAoGBAMfuE0Nrw9Fq7f8+U/SsqiW9djJp4R34EF5n8qHkotfRoAbGktCGxLoF
QMbB9X0ibRMpxEKPHj+V0FXu9zUKFuqoriRc3alQYLNzJEdKeQQ/AN5xjG3ilM6D
/FunImbvSdJLjR9Ue6vlFdOquHevBCFDiHOJPQJ/y4qyZR5Avluw
-----END RSA PRIVATE KEY-----

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +0,0 @@
{
"name": "openvidu-mvc-node",
"version": "2.22.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/OpenVidu/openvidu-tutorials.git"
},
"author": "openvidu@gmail.com",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/OpenVidu/openvidu-tutorials/issues"
},
"homepage": "https://github.com/OpenVidu/openvidu-tutorials#readme",
"dependencies": {
"body-parser": "1.19.0",
"ejs": "3.1.6",
"express": "4.17.1",
"express-session": "1.17.1",
"openvidu-node-client": "2.22.0"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

File diff suppressed because one or more lines are too long

View File

@ -1,377 +0,0 @@
html {
position: relative;
min-height: 100%;
}
nav {
height: 50px;
width: 100%;
z-index: 1;
background-color: #4d4d4d !important;
border-color: #4d4d4d !important;
border-top-right-radius: 0 !important;
border-top-left-radius: 0 !important;
}
.navbar-header {
width: 100%;
}
.nav-icon {
padding: 5px 15px 5px 15px;
float: right;
}
nav a {
color: #ccc !important;
}
nav i.fa {
font-size: 40px;
color: #ccc;
}
nav a:hover {
color: #a9a9a9 !important;
}
nav i.fa:hover {
color: #a9a9a9;
}
#main-container {
padding-bottom: 80px;
}
.vertical-center {
width: -webkit-fit-content;
width: fit-content;
margin: auto;
}
.vertical-center#not-logged form {
width: -moz-fit-content;
margin: auto;
}
.vertical-center#not-logged table {
width: -moz-fit-content;
margin: auto;
}
.vertical-center table {
margin-top: 3em !important;
}
.horizontal-center {
margin: 0 auto;
}
.form-control {
color: #0088aa;
font-weight: bold;
}
.form-control:focus {
border-color: #0088aa;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(0, 136, 170, 0.6);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(0, 136, 170, 0.6);
}
input.btn {
font-weight: bold;
}
.btn {
font-weight: bold !important;
}
.btn-success {
background-color: #06d362 !important;
border-color: #06d362;
}
.btn-success:hover {
background-color: #1abd61 !important;
border-color: #1abd61;
}
.btn-info {
background-color: #0088aa !important;
border-color: #0088aa;
}
.btn-info:hover {
background-color: #00708c !important;
border-color: #00708c;
}
.btn-warning {
background-color: #ffcc00 !important;
border-color: #ffcc00;
color: #4d4d4d;
}
.btn-warning:hover {
background-color: #eabb3a !important;
border-color: #eabb3a;
color: #4d4d4d;
}
.btn-warning:active {
color: #4d4d4d;
}
.btn-warning:focus {
color: #4d4d4d;
}
.btn-warning:active:focus {
color: #4d4d4d;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
background-color: #4d4d4d;
}
.footer .text-muted {
margin: 20px 0;
float: left;
color: #ccc;
}
.openvidu-logo {
height: 35px;
float: right;
margin: 12px 0;
-webkit-transition: all 0.1s ease-in-out;
-moz-transition: all 0.1s ease-in-out;
-o-transition: all 0.1s ease-in-out;
transition: all 0.1s ease-in-out;
}
.openvidu-logo:hover {
-webkit-filter: grayscale(0.5);
filter: grayscale(0.5);
}
.demo-logo {
margin: 0;
height: 22px;
float: left;
padding-right: 8px;
}
a:hover .demo-logo {
-webkit-filter: brightness(0.7);
filter: brightness(0.7);
}
#join {
padding-top: 40px;
}
#not-logged {
padding-top: 40px;
}
#join-dialog h1 {
color: #4d4d4d;
font-weight: bold;
text-align: center;
}
#join-dialog label {
color: #0088aa;
}
#join-dialog input.btn {
margin-top: 15px;
}
#join-dialog hr {
background: #4d4d4d;
}
#img-div {
text-align: center;
padding-bottom: 3em;
}
#img-div img {
height: 15%;
}
#logged {
width: 100%;
}
#join {
max-width: 700px;
margin: auto;
}
#session-header {
margin-bottom: 20px;
}
#session-header form {
display: inline;
}
#session-title {
display: inline-block;
}
#buttonLeaveSession {
float: right;
margin-top: 20px;
}
#video-container video {
position: relative;
float: left;
width: 50%;
cursor: pointer;
}
#video-container div {
float: left;
width: 50%;
position: relative;
margin-left: -50%;
}
#video-container p {
display: inline-block;
background: #f8f8f8;
padding-left: 5px;
padding-right: 5px;
color: #777777;
font-weight: bold;
border-bottom-right-radius: 4px;
}
#video-container p.userName {
float: right;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 0px;
font-weight: lighter;
font-size: 12px;
background: #777777;
color: #f8f8f8;
}
video {
width: 100%;
height: auto;
}
#main-video p {
position: absolute;
display: inline-block;
background: #f8f8f8;
padding-left: 5px;
padding-right: 5px;
font-size: 22px;
color: #777777;
font-weight: bold;
border-bottom-right-radius: 4px;
}
#main-video p.userName {
position: absolute;
right: 0;
font-size: 16px !important;
margin-right: 15px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 0px;
font-weight: lighter;
font-size: 12px;
background: #777777;
color: #f8f8f8;
}
#session img {
width: 100%;
height: auto;
display: inline-block;
object-fit: contain;
vertical-align: baseline;
}
#session #video-container img {
position: relative;
float: left;
width: 50%;
cursor: pointer;
object-fit: cover;
height: 180px;
}
table i {
cursor: pointer;
margin-left: 1em;
}
#tooltip-div {
text-align: left;
}
#tooltip-div hr {
margin: 5px 0;
}
#login-info {
text-align: right;
}
#login-info form {
display: inline;
}
#login-info div {
display: inline;
margin-right: 1em;
}
#name-user {
font-weight: bold;
}
/* xs ans md screen resolutions*/
@media screen and (max-width: 991px) {
#join {
padding-top: inherit;
}
#not-logged {
padding-top: inherit;
}
.container .navbar-header {
margin-right: 0 !important;
margin-left: 0 !important;
}
.nav-icon {
padding: 9px 8px 9px 8px;
}
nav i.fa {
font-size: 32px;
}
.vertical-center {
padding-top: 10px;
}
#img-div {
padding-bottom: 1em;
}
#img-div img {
height: 10%;
}
}

View File

@ -1,284 +0,0 @@
/* CONFIGURATION */
var OpenVidu = require('openvidu-node-client').OpenVidu;
var OpenViduRole = require('openvidu-node-client').OpenViduRole;
// Check launch arguments: must receive openvidu-server URL and the secret
if (process.argv.length != 4) {
console.log("Usage: node " + __filename + " OPENVIDU_URL OPENVIDU_SECRET");
process.exit(-1);
}
// For demo purposes we ignore self-signed certificate
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
// Node imports
var express = require('express');
var fs = require('fs');
var session = require('express-session');
var https = require('https');
var bodyParser = require('body-parser'); // Pull information from HTML POST (express4)
var app = express(); // Create our app with express
// Server configuration
app.use(session({
saveUninitialized: true,
resave: false,
secret: 'MY_SECRET'
}));
app.use(express.static(__dirname + '/public')); // Set the static files location
app.use(bodyParser.urlencoded({
'extended': 'true'
})); // Parse application/x-www-form-urlencoded
app.use(bodyParser.json()); // Parse application/json
app.use(bodyParser.json({
type: 'application/vnd.api+json'
})); // Parse application/vnd.api+json as json
app.set('view engine', 'ejs'); // Embedded JavaScript as template engine
// Listen (start app with node server.js)
var options = {
key: fs.readFileSync('openvidukey.pem'),
cert: fs.readFileSync('openviducert.pem')
};
https.createServer(options, app).listen(5000);
// Mock database
var users = [{
user: "publisher1",
pass: "pass",
role: OpenViduRole.PUBLISHER
}, {
user: "publisher2",
pass: "pass",
role: OpenViduRole.PUBLISHER
}, {
user: "subscriber",
pass: "pass",
role: OpenViduRole.SUBSCRIBER
}];
// Environment variable: URL where our OpenVidu server is listening
var OPENVIDU_URL = process.argv[2];
// Environment variable: secret shared with our OpenVidu server
var OPENVIDU_SECRET = process.argv[3];
// Entrypoint to OpenVidu Node Client SDK
var OV = new OpenVidu(OPENVIDU_URL, OPENVIDU_SECRET);
// Collection to pair session names with OpenVidu Session objects
var mapSessions = {};
// Collection to pair session names with tokens
var mapSessionNamesTokens = {};
console.log("App listening on port 5000");
/* CONFIGURATION */
/* REST API */
app.post('/', loginController);
app.get('/', loginController);
function loginController(req, res) {
if (req.session.loggedUser) { // User is logged
user = req.session.loggedUser;
res.redirect('/dashboard');
} else { // User is not logged
req.session.destroy();
res.render('index.ejs');
}
}
app.post('/logout', (req, res) => {
req.session.destroy();
res.redirect('/');
});
app.post('/dashboard', dashboardController);
app.get('/dashboard', dashboardController);
function dashboardController(req, res) {
// Check if the user is already logged in
if (isLogged(req.session)) {
// User is already logged. Immediately return dashboard
user = req.session.loggedUser;
res.render('dashboard.ejs', {
user: user
});
} else {
// User wasn't logged and wants to
// Retrieve params from POST body
var user = req.body.user;
var pass = req.body.pass;
console.log("Logging in | {user, pass}={" + user + ", " + pass + "}");
if (login(user, pass)) { // Correct user-pass
// Validate session and return OK
// Value stored in req.session allows us to identify the user in future requests
console.log("'" + user + "' has logged in");
req.session.loggedUser = user;
res.render('dashboard.ejs', {
user: user
});
} else { // Wrong user-pass
// Invalidate session and return index template
console.log("'" + user + "' invalid credentials");
req.session.destroy();
res.redirect('/');
}
}
}
app.post('/session', (req, res) => {
if (!isLogged(req.session)) {
req.session.destroy();
res.redirect('/');
} else {
// The nickname sent by the client
var clientData = req.body.data;
// The video-call to connect
var sessionName = req.body.sessionname;
// Role associated to this user
var role = users.find(u => (u.user === req.session.loggedUser)).role;
// Optional data to be passed to other users when this user connects to the video-call
// In this case, a JSON with the value we stored in the req.session object on login
var serverData = JSON.stringify({ serverData: req.session.loggedUser });
console.log("Getting a token | {sessionName}={" + sessionName + "}");
// Build connectionProperties object with the serverData and the role
var connectionProperties = {
data: serverData,
role: role
};
if (mapSessions[sessionName]) {
// Session already exists
console.log('Existing session ' + sessionName);
// Get the existing Session from the collection
var mySession = mapSessions[sessionName];
// Generate a new token asynchronously with the recently created connectionProperties
mySession.createConnection(connectionProperties)
.then(connection => {
// Store the new token in the collection of tokens
mapSessionNamesTokens[sessionName].push(connection.token);
// Return session template with all the needed attributes
res.render('session.ejs', {
sessionId: mySession.getSessionId(),
token: connection.token,
nickName: clientData,
userName: req.session.loggedUser,
sessionName: sessionName
});
})
.catch(error => {
console.error(error);
});
} else {
// New session
console.log('New session ' + sessionName);
// Create a new OpenVidu Session asynchronously
OV.createSession()
.then(session => {
// Store the new Session in the collection of Sessions
mapSessions[sessionName] = session;
// Store a new empty array in the collection of tokens
mapSessionNamesTokens[sessionName] = [];
// Generate a new token asynchronously with the recently created connectionProperties
session.createConnection(connectionProperties)
.then(connection => {
// Store the new token in the collection of tokens
mapSessionNamesTokens[sessionName].push(connection.token);
// Return session template with all the needed attributes
res.render('session.ejs', {
sessionName: sessionName,
token: connection.token,
nickName: clientData,
userName: req.session.loggedUser,
});
})
.catch(error => {
console.error(error);
});
})
.catch(error => {
console.error(error);
});
}
}
});
app.post('/leave-session', (req, res) => {
if (!isLogged(req.session)) {
req.session.destroy();
res.render('index.ejs');
} else {
// Retrieve params from POST body
var sessionName = req.body.sessionname;
var token = req.body.token;
console.log('Removing user | {sessionName, token}={' + sessionName + ', ' + token + '}');
// If the session exists
if (mapSessions[sessionName] && mapSessionNamesTokens[sessionName]) {
var tokens = mapSessionNamesTokens[sessionName];
var index = tokens.indexOf(token);
// If the token exists
if (index !== -1) {
// Token removed
tokens.splice(index, 1);
console.log(sessionName + ': ' + tokens.toString());
} else {
var msg = 'Problems in the app server: the TOKEN wasn\'t valid';
console.log(msg);
res.redirect('/dashboard');
}
if (tokens.length == 0) {
// Last user left: session must be removed
console.log(sessionName + ' empty!');
delete mapSessions[sessionName];
}
res.redirect('/dashboard');
} else {
var msg = 'Problems in the app server: the SESSION does not exist';
console.log(msg);
res.status(500).send(msg);
}
}
});
/* REST API */
/* AUXILIARY METHODS */
function login(user, pass) {
return (user != null &&
pass != null &&
users.find(u => (u.user === user) && (u.pass === pass)));
}
function isLogged(session) {
return (session.loggedUser != null);
}
function getBasicAuth() {
return 'Basic ' + (new Buffer('OPENVIDUAPP:' + OPENVIDU_SECRET).toString('base64'));
}
/* AUXILIARY METHODS */

View File

@ -1,82 +0,0 @@
<html>
<head>
<title>openvidu-mvc-node</title>
<meta name="viewport" content="width=device-width, initial-scale=1" charset="utf-8"></meta>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon"></link>
<!-- Bootstrap -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g="
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous"></link>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"></link>
<!-- Bootstrap -->
<link rel="styleSheet" href="style.css" type="text/css" media="screen"></link>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/"><img class="demo-logo" src="images/openvidu_vert_white_bg_trans_cropped.png"/> MVC Node</a>
<a class="navbar-brand nav-icon" href="https://github.com/OpenVidu/openvidu-tutorials/tree/master/openvidu-mvc-node" title="GitHub Repository"
target="_blank"><i class="fa fa-github" aria-hidden="true"></i></a>
<a class="navbar-brand nav-icon" href="http://www.docs.openvidu.io/en/stable/tutorials/openvidu-mvc-node/" title="Documentation" target="_blank"><i class="fa fa-book" aria-hidden="true"></i></a>
</div>
</div>
</nav>
<div id="main-container" class="container">
<div id="logged">
<div id="join" class="vertical-center">
<div id="img-div"><img src="images/openvidu_grey_bg_transp_cropped.png" /></div>
<div id="join-dialog" class="jumbotron">
<h1>Join a video session</h1>
<form class="form-group" action="/session" method="post">
<p>
<label>Participant</label>
<input class="form-control" type="text" name="data" required="true"></input>
</p>
<p>
<label>Session</label>
<input class="form-control" type="text" name="sessionname" required="true"></input>
</p>
<p class="text-center">
<button class="btn btn-lg btn-success" type="submit">Join!</button>
</p>
</form>
<hr></hr>
<div id="login-info">
<div>Logged as <span id="name-user"><%= user %></span></div>
<form action="/logout" method="post">
<button id="logout-btn" class="btn btn-warning" type="submit">Log out</button>
</form>
</div>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<div class="text-muted">OpenVidu © 2022</div>
<a href="http://www.openvidu.io/" target="_blank"><img class="openvidu-logo" src="images/openvidu_globe_bg_transp_cropped.png"/></a>
</div>
</footer>
</body>
<script>
window.onload = function () { // Generate participant info
$("input[name='sessionname']").val("Session " + Math.floor(Math.random() * 10));
$("input[name='data']").val("Participant " + Math.floor(Math.random() * 100));
}
</script>
</html>

View File

@ -1,93 +0,0 @@
<html>
<head>
<title>openvidu-mvc-node</title>
<meta name="viewport" content="width=device-width, initial-scale=1" charset="utf-8"></meta>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon"></link>
<!-- Bootstrap -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g="
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous"></link>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"></link>
<!-- Bootstrap -->
<link rel="styleSheet" href="style.css" type="text/css" media="screen"></link>
<script>
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip({
html: true
});
});
</script>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/"><img class="demo-logo" src="images/openvidu_vert_white_bg_trans_cropped.png"/> MVC Node</a>
<a class="navbar-brand nav-icon" href="https://github.com/OpenVidu/openvidu-tutorials/tree/master/openvidu-mvc-node" title="GitHub Repository"
target="_blank"><i class="fa fa-github" aria-hidden="true"></i></a>
<a class="navbar-brand nav-icon" href="http://www.docs.openvidu.io/en/stable/tutorials/openvidu-mvc-node/" title="Documentation" target="_blank"><i class="fa fa-book" aria-hidden="true"></i></a>
</div>
</div>
</nav>
<div id="main-container" class="container">
<div id="not-logged" class="vertical-center">
<div id="img-div"><img src="images/openvidu_grey_bg_transp_cropped.png" /></div>
<form class="form-group jumbotron" action="/dashboard" method="post">
<p>
<label>User</label>
<input class="form-control" type="text" name="user" required="true"></input>
</p>
<p>
<label>Pass</label>
<input class="form-control" type="password" name="pass" required="true"></input>
</p>
<p class="text-center">
<button class="btn btn-lg btn-info" type="submit">Log in</button>
</p>
</form>
<table class="table">
<tr>
<th>User</th>
<th>Pass</th>
<th>Role<i data-toggle="tooltip" data-placement="bottom" title="" data-original-title="&lt;div id='tooltip-div'&gt;PUBLISHER&lt;div&gt;Send and receive media&lt;hr&gt;&lt;/div&gt;SUBSCRIBER&lt;div&gt;Receive media&lt;/div&gt;&lt;/div&gt;"
class="glyphicon glyphicon-info-sign"></i></th>
</tr>
<tr>
<td>publisher1</td>
<td>pass</td>
<td>PUBLISHER</td>
</tr>
<tr>
<td>publisher2</td>
<td>pass</td>
<td>PUBLISHER</td>
</tr>
<tr>
<td>subscriber</td>
<td>pass</td>
<td>SUBSCRIBER</td>
</tr>
</table>
</div>
</div>
<footer class="footer">
<div class="container">
<div class="text-muted">OpenVidu © 2022</div>
<a href="http://www.openvidu.io/" target="_blank"><img class="openvidu-logo" src="images/openvidu_globe_bg_transp_cropped.png"/></a>
</div>
</footer>
</body>
</html>

View File

@ -1,253 +0,0 @@
<html>
<head>
<title>openvidu-mvc-node</title>
<meta name="viewport" content="width=device-width, initial-scale=1" charset="utf-8"></meta>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon"></link>
<!-- Bootstrap -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"></link>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"></link>
<!-- Bootstrap -->
<link rel="styleSheet" href="style.css" type="text/css" media="screen"></link>
<script src="openvidu-browser-2.22.0.js"></script>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/">
<img class="demo-logo" src="images/openvidu_vert_white_bg_trans_cropped.png" /> MVC Node</a>
<a class="navbar-brand nav-icon" href="https://github.com/OpenVidu/openvidu-tutorials/tree/master/openvidu-mvc-node" title="GitHub Repository"
target="_blank">
<i class="fa fa-github" aria-hidden="true"></i>
</a>
<a class="navbar-brand nav-icon" href="http://www.docs.openvidu.io/en/stable/tutorials/openvidu-mvc-node/" title="Documentation" target="_blank">
<i class="fa fa-book" aria-hidden="true"></i>
</a>
</div>
</div>
</nav>
<div id="main-container" class="container">
<div id="logged">
<div id="session">
<div id="session-header">
<h1 id="session-title"><%= sessionName %></h1>
<form action="/leave-session" method="post">
<input type="hidden" name="sessionname" value="<%= sessionName %>"></input>
<input type="hidden" name="token" value="<%= token %>"></input>
<button id="buttonLeaveSession" class="btn btn-large btn-danger" type="submit" onclick="leaveSession()">
Leave session</button>
</form>
</div>
<div id="main-video" class="col-md-6">
<p class="nickName"></p>
<p class="userName"></p>
<video autoplay="true" playsinline="true"></video>
</div>
<div id="video-container" class="col-md-6"></div>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<div class="text-muted">OpenVidu © 2022</div>
<a href="http://www.openvidu.io/" target="_blank">
<img class="openvidu-logo" src="images/openvidu_globe_bg_transp_cropped.png" />
</a>
</div>
</footer>
</body>
<script>
// Get all the attributes from the template in EJS style
var sessionName = <%- JSON.stringify(sessionName) %>;
var token = <%- JSON.stringify(token) %>;
var nickName = <%- JSON.stringify(nickName) %>;
var userName = <%- JSON.stringify(userName) %>;
console.warn('Request of TOKEN gone WELL (TOKEN:' + token + ')');
// --- 1) Get an OpenVidu object ---
OV = new OpenVidu();
// --- 2) Init a session ---
session = OV.initSession();
// --- 3) Specify the actions when events take place in the session ---
// On every new Stream received...
session.on('streamCreated', (event) => {
// Subscribe to the Stream to receive it
// HTML video will be appended to element with 'video-container' id
var subscriber = session.subscribe(event.stream, 'video-container');
// When the HTML video has been appended to DOM...
subscriber.on('videoElementCreated', (event) => {
// Add a new HTML element for the user's name and nickname over its video
appendUserData(event.element, subscriber.stream.connection);
});
});
// On every Stream destroyed...
session.on('streamDestroyed', (event) => {
// Delete the HTML element with the user's name and nickname
removeUserData(event.stream.connection);
});
// On every asynchronous exception...
session.on('exception', (exception) => {
console.warn(exception);
});
// --- 4) Connect to the session passing the retrieved token and some more data from
// the client (in this case a JSON with the nickname chosen by the user) ---
session.connect(token, { clientData: nickName })
.then(() => {
// --- 5) Set page layout for active call ---
$('#session-title').text(sessionName);
$('#join').hide();
$('#session').show();
// Here we check somehow if the user has 'PUBLISHER' role before
// trying to publish its stream. Even if someone modified the client's code and
// published the stream, it wouldn't work if the token sent in Session.connect
// method is not recognized as 'PUBLIHSER' role by OpenVidu Server
if (isPublisher()) {
// --- 6) Get your own camera stream ---
var publisher = OV.initPublisher('video-container', {
audioSource: undefined, // The source of audio. If undefined default microphone
videoSource: undefined, // The source of video. If undefined default webcam
publishAudio: true, // Whether you want to start publishing with your audio unmuted or not
publishVideo: true, // Whether you want to start publishing with your video enabled or not
resolution: '640x480', // The resolution of your video
frameRate: 30, // The frame rate of your video
insertMode: 'APPEND', // How the video is inserted in the target element 'video-container'
mirror: false // Whether to mirror your local video or not
});
// --- 7) Specify the actions when events take place in our publisher ---
// When our HTML video has been added to DOM...
publisher.on('videoElementCreated', (event) => {
// Init the main video with ours and append our data
var userData = {
nickName: nickName,
userName: userName
};
initMainVideo(event.element, userData);
appendUserData(event.element, userData);
$(event.element).prop('muted', true); // Mute local video
});
// --- 8) Publish your stream ---
session.publish(publisher);
} else {
console.warn('You don\'t have permissions to publish');
initMainVideoThumbnail(); // Show SUBSCRIBER message in main video
}
})
.catch(error => {
console.warn('There was an error connecting to the session:', error.code, error.message);
});
function leaveSession() {
// --- 9) Leave the session by calling 'disconnect' method over the Session object ---
session.disconnect();
}
function appendUserData(videoElement, connection) {
var clientData;
var serverData;
var nodeId;
if (connection.nickName) { // Appending local video data
clientData = connection.nickName;
serverData = connection.userName;
nodeId = 'main-videodata';
} else {
clientData = JSON.parse(connection.data.split('%/%')[0]).clientData;
serverData = JSON.parse(connection.data.split('%/%')[1]).serverData;
nodeId = connection.connectionId;
}
var dataNode = document.createElement('div');
dataNode.className = "data-node";
dataNode.id = "data-" + nodeId;
dataNode.innerHTML = '<p class="nickName">' + clientData + '</p><p class="userName">' + serverData + '</p>';
videoElement.parentNode.insertBefore(dataNode, videoElement.nextSibling);
addClickListener(videoElement, clientData, serverData);
}
function removeUserData(connection) {
var userNameRemoved = $("#data-" + connection.connectionId);
if ($(userNameRemoved).find('p.userName').html() === $('#main-video p.userName').html()) {
cleanMainVideo(); // The participant focused in the main video has left
}
$("#data-" + connection.connectionId).remove();
}
function removeAllUserData() {
$(".data-node").remove();
}
function cleanMainVideo() {
$('#main-video video').get(0).srcObject = null;
$('#main-video p').each(function () {
$(this).html('');
});
}
function addClickListener(videoElement, clientData, serverData) {
videoElement.addEventListener('click', function () {
var mainVideo = $('#main-video video').get(0);
if (mainVideo.srcObject !== videoElement.srcObject) {
$('#main-video').fadeOut("fast", () => {
$('#main-video p.nickName').html(clientData);
$('#main-video p.userName').html(serverData);
mainVideo.srcObject = videoElement.srcObject;
$('#main-video').fadeIn("fast");
});
}
});
}
function initMainVideo(videoElement, userData) {
$('#main-video video').get(0).srcObject = videoElement.srcObject;
$('#main-video p.nickName').html(userData.nickName);
$('#main-video p.userName').html(userData.userName);
$('#main-video video').prop('muted', true);
}
function initMainVideoThumbnail() {
$('#main-video video').css("background", "url('images/subscriber-msg.jpg') round");
}
function isPublisher() {
return userName.includes('publisher');
}
</script>
</html>