- Timestamp:
- 05/13/12 21:48:13 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
etherws/trunk/etherws.py
r138 r139 9 9 # - websocket-client-0.7.0 10 10 # - tornado-2.2.1 11 #12 # todo:13 # - direct binary transmission support (to improve performance)14 11 # 15 12 # =========================================================================== … … 43 40 import os 44 41 import sys 45 import base6446 42 import argparse 47 43 import threading … … 76 72 sys.stderr.write('%s: %s\n' % (caller.__class__.__name__, 77 73 message.encode('hex'))) 78 79 74 try: 80 75 self._write_lock.acquire() … … 86 81 self._tap.write(message) 87 82 88 message = base64.b64encode(message)89 90 83 for c in clients: 91 c.write_message(message )84 c.write_message(message, True) 92 85 93 86 finally: … … 108 101 109 102 def on_message(self, message): 110 self._tap.write(self, base64.b64decode(message))103 self._tap.write(self, message) 111 104 112 105 def on_close(self): … … 158 151 tap = TapHandler(args.device, debug=args.debug) 159 152 client = websocket.WebSocketApp(args.uri) 160 client.write_message = client.send 161 client.on_message = lambda s, m: tap.write(client, base64.b64decode(m)) 153 client.on_message = lambda s, m: tap.write(client, m) 154 client.write_message = \ 155 lambda m, b: client.sock.send(m, websocket.ABNF.OPCODE_BINARY) 162 156 tap.register_client(client) 163 157
Note: See TracChangeset
for help on using the changeset viewer.