summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorliris <liris.pp@gmail.com>2015-05-13 08:22:50 +0900
committerliris <liris.pp@gmail.com>2015-05-13 08:22:50 +0900
commitf6af085e1a393a7ef8b7d194330b46e16ab217e2 (patch)
tree9913f8c4645621b183db92c17f264375e57a01ff /bin
parent8f7a4c7fefcb9fcdd5471e7d37e67011410d134d (diff)
downloadwebsocket-client-f6af085e1a393a7ef8b7d194330b46e16ab217e2.tar.gz
fixed #183
Diffstat (limited to 'bin')
-rwxr-xr-xbin/wsdump.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/bin/wsdump.py b/bin/wsdump.py
index d98d240..00cd5eb 100755
--- a/bin/wsdump.py
+++ b/bin/wsdump.py
@@ -5,6 +5,7 @@ import code
import six
import sys
import threading
+import time
import websocket
try:
import readline
@@ -12,8 +13,17 @@ except:
pass
+def get_encoding():
+ encoding = getattr(sys.stdin, "encoding", "")
+ if not encoding:
+ return "utf-8"
+ else:
+ return encoding.lower()
+
+
OPCODE_DATA = (websocket.ABNF.OPCODE_TEXT, websocket.ABNF.OPCODE_BINARY)
-ENCODING = getattr(sys.stdin, "encoding", "").lower()
+ENCODING = get_encoding()
+
class VAction(argparse.Action):
def __call__(self, parser, args, values, option_string=None):
@@ -105,6 +115,7 @@ def main():
def recv_ws():
while True:
opcode, data = recv()
+ print(data)
msg = None
if not args.verbose and opcode in OPCODE_DATA:
msg = "< %s" % data
@@ -128,6 +139,7 @@ def main():
try:
message = console.raw_input("> ")
ws.send(message)
+ time.sleep(0.05)
except KeyboardInterrupt:
return
except EOFError: