2017-02-23 57 views
0

我正在创建一个用于学习目的的示例项目(稍后我将在基于webrtc和kurento的项目上工作),我正在使用Kurento媒体服务器,我修改了kurento服务器的教程并制作了一个样本的。我们是否需要在WebRTC中进行会话?

在所有样品Kurento服务器他们用的是UserRegistry.java在那里它们被存储UserSession的对象,如下图所示:

public class UserSession { 

    private static final Logger log = LoggerFactory.getLogger(UserSession.class); 

    private final String name; 
    private final WebSocketSession session; 

    private String sdpOffer; 
    private String callingTo; 
    private String callingFrom; 
    private WebRtcEndpoint webRtcEndpoint; 
    private WebRtcEndpoint playingWebRtcEndpoint; 
    private final List<IceCandidate> candidateList = new ArrayList<>(); 

    public UserSession(WebSocketSession session, String name) { 
    this.session = session; 
    this.name = name; 
    } 

    public void sendMessage(JsonObject message) throws IOException { 
    log.debug("Sending message from user '{}': {}", name, message); 
    session.sendMessage(new TextMessage(message.toString())); 
    } 

    public String getSessionId() { 
    return session.getId(); 
    } 

    public void setWebRtcEndpoint(WebRtcEndpoint webRtcEndpoint) { 
    this.webRtcEndpoint = webRtcEndpoint; 

    if (this.webRtcEndpoint != null) { 
     for (IceCandidate e : candidateList) { 
     this.webRtcEndpoint.addIceCandidate(e); 
     } 
     this.candidateList.clear(); 
    } 
    } 

    public void addCandidate(IceCandidate candidate) { 
    if (this.webRtcEndpoint != null) { 
     this.webRtcEndpoint.addIceCandidate(candidate); 
    } else { 
     candidateList.add(candidate); 
    } 

    if (this.playingWebRtcEndpoint != null) { 
     this.playingWebRtcEndpoint.addIceCandidate(candidate); 
    } 
    } 

    public void clear() { 
    this.webRtcEndpoint = null; 
    this.candidateList.clear(); 
    } 
} 

我对这两个问题:

  1. 为什么我们需要会话对象?
  2. 什么是管理会话的替代方案(如果有的话)?

让我给出第二个问题的更多背景。我发现我只能在客户端运行Kurento-JavaScript-Client(我需要将其转换为浏览器版本,然后才能使用它)(这样我就不需要后端服务器,即nodejs或tomcat - 这是我的假设)。所以在这种情况下,我将如何管理会话,或者我可以完全删除UserRegistry概念并使用其他方式。

感谢&问候

回答

0

您需要存储会话实现客户端和应用服务器之间的信令。例如参见here。信令图描述启动/停止/等WebRTC视频通信所需的消息。

如果您计划摆脱应用程序服务器(即完全转移到JavaScript客户端),则可以查看发布/订阅API,如PubNub

+0

谢谢,但我仍然有一个问题,我可以完全从客户端使用Kurento-JS-客户端,即仅从客户端创建会话,还是会包含任何安全问题?我不想为此使用任何专有软件/服务。 –

+0

当然,Kurento是开源的(Apache 2.0许可证)。 –

相关问题