我使用高速公路0.4.10(https://github.com/oberstet/Autobahn)作为WebSocket的服务器将消息发送到谷歌的Chrome扩展不会被调用。我可以使用WebSocket()
打开和关闭连接,但是当我打电话给autobahn.websocket.WebSocketServerProtocol.sendMessage()
时,该消息显示为已发送,但在连接关闭之前不会发送。的WebSocket的onMessage()发送消息时,
为WebSocketServerProtocol的sendMessage()
的API(从WebSocketProtocol派生)可以在这里找到:http://www.tavendo.de/autobahn/doc/python/websocketprotocol.html#autobahn.websocket.WebSocketProtocol
有没有人遇到过这个问题?
我一直在客户端的代码(JS):
ws = new WebSocket('ws://localhost:4444');
ws.onmessage = function(event) {
console.log('hii');
}
而且服务器(蟒蛇)上...
#json is a string object
def sendEvent(self, json):
print 'to', self.peerstr
self.sendMessage(json, sync=True)
两个高速公路和我的版本的Chrome( 17.0.963.46)出现(从我的头文件和文档中获得)使用WebSocket草案版本13的协议。
感谢您的答复,实际上只是发现了问题(回答上文)。我会取消同步= True选项 - 不知道我在哪里得到它。 – Lchi 2012-02-24 20:49:09