我们需要WebRTC中的会话吗?

我们需要WebRTC中的会话吗?,webrtc,kurento,Webrtc,Kurento,我正在创建一个用于学习的示例项目(稍后我将在基于webrtc和kurento的项目上工作),我正在使用kurento媒体服务器,我修改了kurento服务器的教程,并制作了一个示例 在Kurento Server的所有示例中,他们都使用UserRegistry.java存储UserSession的对象,如下所示: public class UserSession { private static final Logger log = LoggerFactory.getLogger(User

我正在创建一个用于学习的示例项目(稍后我将在基于webrtc和kurento的项目上工作),我正在使用kurento媒体服务器,我修改了kurento服务器的教程,并制作了一个示例

在Kurento Server的所有示例中,他们都使用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();
  }
}
公共类用户会话{
私有静态最终记录器log=LoggerFactory.getLogger(UserSession.class);
私有最终字符串名;
非公开最终WebSocketSession;
专用字符串sdpOffer;
私人字符串调用;
从中调用的私有字符串;
私有WebRTC端点WebRTC端点;
私有WebRtcEndpoint播放WebRtcEndpoint;
private final List candidateList=new ArrayList();
公共用户会话(WebSocketSession会话,字符串名称){
this.session=会话;
this.name=名称;
}
公共void sendMessage(JsonObject消息)引发IOException{
调试(“从用户“{}”发送消息:{}”,名称,消息);
session.sendMessage(新文本消息(message.toString());
}
公共字符串getSessionId(){
return session.getId();
}
public void setWebRtcEndpoint(WebRtcEndpoint WebRtcEndpoint){
this.webRtcEndpoint=webRtcEndpoint;
如果(this.webRtcEndpoint!=null){
申请者(候选人e:候选人名单){
this.webRtcEndpoint.addIceCandidate(e);
}
这个.candidateList.clear();
}
}
公共候选(ICE候选){
如果(this.webRtcEndpoint!=null){
this.webRtcEndpoint.addIceCandidate(候选);
}否则{
候选人名单。添加(候选人);
}
if(this.playingWebRtcEndpoint!=null){
this.playingWebRtcEndpoint.addIceCandidate(候选);
}
}
公共空间清除(){
this.webRtcEndpoint=null;
这个.candidateList.clear();
}
}
关于这一点,我有两个问题:

  • 为什么我们需要会话对象
  • 管理会话的备选方案有哪些(如果有的话) 让我就第二个问题提供更多的背景资料。我发现我可以只在客户端运行Kurento JavaScript客户端(我需要将其转换为浏览器版本,然后才能使用它)(这样我就不需要后端服务器,即nodejs或tomcat——这是我的假设)。所以在这种情况下,我将如何管理会话,或者我可以完全删除UserRegistry的概念并使用其他方法


    感谢和问候

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


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

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


    如果您打算摆脱应用服务器(即完全转移到JavaScript客户端),您可以查看发布/订阅API,例如。

    谢谢,但我仍然有一个问题,我是否可以完全从客户端使用Kurento JS客户端,即仅从客户端创建会话,或者它是否包含任何安全问题?我不想为此使用任何专有软件/服务。当然,Kurento是开源的(Apache 2.0许可)。谢谢,但我仍然有一个问题,我可以完全从客户端使用Kurento JS客户端,即仅从客户端创建会话,还是会包括任何安全问题?我不想为此使用任何专有软件/服务。当然,Kurento是开源的(Apache 2.0许可证)。