Changeset 139 for etherws


Ignore:
Timestamp:
05/13/12 21:48:13 (13 years ago)
Author:
atzm
Message:
  • add direct binary transmission support (to improve performance)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • etherws/trunk/etherws.py

    r138 r139  
    99#   - websocket-client-0.7.0 
    1010#   - tornado-2.2.1 
    11 # 
    12 # todo: 
    13 #   - direct binary transmission support (to improve performance) 
    1411# 
    1512# =========================================================================== 
     
    4340import os 
    4441import sys 
    45 import base64 
    4642import argparse 
    4743import threading 
     
    7672            sys.stderr.write('%s: %s\n' % (caller.__class__.__name__, 
    7773                                           message.encode('hex'))) 
    78  
    7974        try: 
    8075            self._write_lock.acquire() 
     
    8681                self._tap.write(message) 
    8782 
    88             message = base64.b64encode(message) 
    89  
    9083            for c in clients: 
    91                 c.write_message(message) 
     84                c.write_message(message, True) 
    9285 
    9386        finally: 
     
    108101 
    109102    def on_message(self, message): 
    110         self._tap.write(self, base64.b64decode(message)) 
     103        self._tap.write(self, message) 
    111104 
    112105    def on_close(self): 
     
    158151    tap = TapHandler(args.device, debug=args.debug) 
    159152    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) 
    162156    tap.register_client(client) 
    163157 
Note: See TracChangeset for help on using the changeset viewer.