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

View File

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