不知道是否有人知道我在这里做错了什么:
我一直在关注:http://blog.felixhagspiel.de/index.php/posts/create-your-own-videochat-application-with-html-and-javascript
正如所解释的,该指南运行得非常好,我已经通过nodejs进行了测试,一切都非常好。
我现在正在尝试将示例移植到groovy中。在grails插件中并遇到一些问题。
所以我现在的处境是:对不起,实际代码的状态让我有一段时间头撞在砖墙上:)
所有者/服务器创建房间-精细
客户端出现并发送报价(收到报价,但客户端上的websocket断开连接)
服务器/所有者收到报价,但在尝试发送回复时-由于客户端断开连接,因此不会发送任何回复。。。。
https://github.com/vahidhedayati/playground/blob/master/grails-wschat-plugin/src/groovy/grails/plugin/wschat/WsCamEndpoint.groovy#L72
这是websocket发送到解析操作的扩展类的地方:
https://github.com/vahidhedayati/playground/blob/master/grails-wschat-plugin/src/groovy/grails/plugin/wschat/ChatUtils.groovy#L244
呼叫:
https://github.com/vahidhedayati/playground/blob/master/grails-wschat-plugin/src/groovy/grails/plugin/wschat/ChatUtils.groovy#L570
https://github.com/vahidhedayati/playground/blob/master/grails-wschat-plugin/src/groovy/grails/plugin/wschat/ChatUtils.groovy#L598
https://github.com/vahidhedayati/playground/blob/master/grails-wschat-plugin/src/groovy/grails/plugin/wschat/ChatUtils.groovy#L575
private void jsonmessageUser(Session userSession,String msg) {
userSession.getBasicRemote().sendText(msg as String)
}
private void jsonmessageOther(Session userSession,String msg) {
Iterator<Session> iterator=camsessions?.iterator()
if (iterator) {
while (iterator?.hasNext()) {
def crec=iterator?.next()
if (crec.isOpen()) {
def cuser=crec.getUserProperties().get("camuser").toString()
def cmuser=crec.getUserProperties().get("camusername").toString()
println "OM ACTIVE USER : ------- ${cuser}"
if (!cuser.toString().endsWith(cmuser)) {
println "----OTHER ||| ${cmuser} :: ${msg}"
crec.getBasicRemote().sendText(msg as String)
}
}
}
}
}
private void jsonmessageOwner(Session userSession,String msg) {
Iterator<Session> iterator=camsessions?.iterator()
if (iterator) {
while (iterator?.hasNext()) {
def crec=iterator?.next()
if (crec.isOpen()) {
def cuser=crec.getUserProperties().get("camuser").toString()
def cmuser=crec.getUserProperties().get("camusername").toString()
if (cuser.toString().endsWith(cmuser)) {
println "----OWNER ||| ${cuser} :: ${msg}"
crec.getBasicRemote().sendText(msg as String)
}
}
}
}
}
现在这就是浏览器上发生的情况:
---服务器:
首先在服务器上,我们登录到local.ip和remote.ip所在的位置,比如192.168.1.6,所以在客户端和服务器上都使用相同的ip,以确保其所有部分都属于相同的连接
http://local.ip.address:8080/testwschat/wsChat/
这为我们提供了一个聊天用户,我们以ff的身份登录
然后手动访问webrtc发送器
http://local.ip.address:8080/testwschat/wsChat/webrtcsend?user=ff
webkit client.js?compile=false:305
Thu Oct 02 2014 16:48:23 GMT+0100 (BST) Connection successfully established client.js?compile=false:220
offer received, answer will be created client.js?compile=false:255
Object {sdp: "v=0
↵o=- 5155933685262328996 2 IN IP4 127.0.0.1
↵s…5748 label:c32aa4ec-9238-4045-b791-0a94ba741b41
↵", type: "offer"} client.js?compile=false:62
stream added client.js?compile=false:168
2icecandidate send to room ff client.js?compile=false:177
Thu Oct 02 2014 16:48:38 GMT+0100 (BST) Connection was closed client.js?compile=false:231
icecandidate send to room ff client.js?compile=false:177
WebSocket is already in CLOSING or CLOSED state. client.js?compile=false:28
icecandidate send to room ff client.js?compile=false:177
WebSocket is already in CLOSING or CLOSED state. client.js?compile=false:28
icecandidate send to room ff client.js?compile=false:177
WebSocket is already in CLOSING or CLOSED state.
---在客户端:
我们首先登录服务器http://remote.ip.address:8080/testwschat/wsChat/
这为我们提供了一个聊天用户,我们在上以cc登录
然后手动访问webrtc接收器
http://remote.ip.address:8080/testwschat/wsChat/webrtcrec?user=ff
sending offer to: ff client.js?compile=false:138
Sending 2 client.js?compile=false:38
4icecandidate send to room ff client.js?compile=false:124
Thu Oct 02 2014 16:48:38 GMT+0100 (BST) Connection was closed client.js?compile=false:231
icecandidate send to room ff client.js?compile=false:124
WebSocket is already in CLOSING or CLOSED state. client.js?compile=false:28
icecandidate send to room ff client.js?compile=false:124
WebSocket is already in CLOSING or CLOSED state. client.js?compile=false:28
icecandidate send to room ff client.js?compile=false:124
WebSocket is already in CLOSING or CLOSED state. client.js?compile=false:28
icecandidate send to room ff client.js?compile=false:124
WebSocket is already in CLOSING or CLOSED state. client.js?compile=false:28
icecandidate send to room ff client.js?compile=false:124
WebSocket is already in CLOSING or CLOSED state. client.js?compile=false:28
根据上面套接字代码中的printlns,实际的后端websocket日志可以在这里看到:
https://gist.github.com/vahidhedayati/6dbd74a1c4a87d373c05
这次又有一些日志是通过网页来控制台sendServer值的,websocket似乎没有接收到icecandidate json。因为后端没有这方面的日志。。也许它的缓冲区有关。。
https://gist.github.com/vahidhedayati/918b731788118de348d0--服务器或所有者浏览器日志
https://gist.github.com/vahidhedayati/a51796f3dcbb14088a31--客户端/其他用户浏览器日志。
伙计们,我认为我上次的调查帮助我回答了自己的问题——缓冲区大小。
因此,如果您使用Java/Govy进行编码,并且希望与webrtc进行交互。你可能会遇到这个问题。解决方法是增加
session.setMaxTextMessageBufferSize(1000000)
当用户打开websocket 时
@OnOpen
public void whenOpening(Session userSession,EndpointConfig c,@PathParam("user") String user,@PathParam("viewer") String viewer) {
if (loggedIn(user)) {
userSession.setMaxBinaryMessageBufferSize(1024*512)
userSession.setMaxTextMessageBufferSize(1000000)
//userSession.setmaxMessageSize(-1L)
if (viewer.equals(user)) {
userSession.getUserProperties().put("camuser", user+":"+user);
}else{
userSession.getUserProperties().put("camuser", user+":"+viewer);
}
if (!camLoggedIn(user)) {
userSession.getUserProperties().put("camusername", user);
camsessions.add(userSession)
}
}else{
log.info "could not find chat user ! ${user}"
}
}