- do closing handshake

This commit is contained in:
Hiroki Ohtani
2011-01-04 12:49:30 +09:00
parent 868722ffa9
commit 0f33b5557b
2 changed files with 13 additions and 6 deletions

View File

@@ -1,8 +1,11 @@
from setuptools import setup
VERSION = "0.3"
setup(
name="websocket-client",
version="0.2",
version=VERSION,
description="WebSocket client for python",
long_description=open("README").read(),
author="liris",
@@ -11,7 +14,7 @@ setup(
url="https://github.com/liris/websocket-client",
classifiers = [
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: LGPL License",
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
"Programming Language :: Python",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX",

View File

@@ -301,9 +301,14 @@ class WebSocket(object):
"""
Close Websocket object
"""
if self.connected and self.version == HYBI00:
# TODO: closing handshake
pass
if self.connected:
try:
self.sock.send("\xff\x00")
result = self._recv(2)
if result != "\xff\x00":
logger.error("bad closing Handshake")
except:
pass
self.sock.close()
def _recv(self, bufsize):
@@ -334,7 +339,6 @@ class WebSocket(object):
if __name__ == "__main__":
enableTrace(True)
#setdefaulttimeout(1)
# ws = create_connection("ws://localhost:8080/echo")
ws = create_connection("ws://localhost:5000/chat")
print "Sending 'Hello, World'..."