improve broadcast demo

This commit is contained in:
Tobias Oberstein
2011-10-03 12:48:32 +02:00
parent defca03639
commit 162cacbcfa
3 changed files with 52 additions and 2 deletions

10
TODO
View File

@@ -68,7 +68,7 @@ REQ = someone asked for it
- REQ: Overview report gets too broad: maybe rotate agent labels in report 90<39> counterclock => css
- REQ: make NON-STRICT more green (yes, was asked by some project to do;)
- REQ: make NON-STRICT more green (yes, was asked by some project to do;) => td.case_almost
- REQ: add notice at top of report overview, explaining diff. beetween PASS, NON-STRICT and FAIL
@@ -111,6 +111,8 @@ Misc Cases
- server must fail for unmasked client frames
- sending a 2^63 frame.
Closing Handshake Cases
-----------------------
@@ -146,6 +148,10 @@ Closing Handshake Cases
- when the fuzzer == server, test client timeout on drop TCP after close
- sending close codes 1005 and 1006 : isn't allowed.
- sending close codes <1000 >=5000 / 1004 is "reserved"
Probably, we need to have a way to instruct the tested peer to iniate a
closing handshake to test certain things (like timeouts).
@@ -184,6 +190,8 @@ Core
WebSocket Protocol
- changes for Hybi-16 .. see also: http://code.google.com/p/pywebsocket/wiki/WebSocketProtocolSpec
- allow FIN = true on beginMessageFrame instead of endMessage
- Further optimize masking: http://stackoverflow.com/questions/2119761/simple-python-challenge-fastest-bitwise-xor-on-data-buffers

View File

@@ -21,6 +21,6 @@
</head>
<body>
<h1>Autobahn WebSockets Broadcast Demo</h1>
<button onclick='webSocket.send("Hello, world!");'>Send Message</button>
<button onclick='webSocket.send("Hello from JavaScript!");'>Send Message</button>
</body>
</html>

View File

@@ -0,0 +1,42 @@
###############################################################################
##
## Copyright 2011 Tavendo GmbH
##
## 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.
##
###############################################################################
import random
from twisted.internet import reactor
from autobahn.websocket import WebSocketClientFactory, WebSocketClientProtocol
class BroadcastClientProtocol(WebSocketClientProtocol):
def sendHello(self):
self.sendMessage("Hello from Python!")
reactor.callLater(random.random()*5, self.sendHello)
def onOpen(self):
self.sendHello()
def onMessage(self, msg, binary):
print "Got message: " + msg
if __name__ == '__main__':
factory = WebSocketClientFactory()
factory.protocol = BroadcastClientProtocol
reactor.connectTCP("localhost", 9000, factory)
reactor.run()