Reviewed code

This commit is contained in:
Roy Hyunjin Han 2013-04-14 23:23:30 -07:00
commit 187c6fbca1
4 changed files with 20 additions and 14 deletions

9
.gitignore vendored
View file

@ -1,8 +1,9 @@
*~ *~
*.sw[op]
*.py[cod]
*.egg
*.egg-info *.egg-info
*.pyc
*.swo
*.swp
.coverage
build build
dist dist
sdist
.coverage

View file

@ -1,4 +1,4 @@
Copyright (c) 2012 Roy Hyunjin Han and contributors Copyright (c) 2013 Roy Hyunjin Han and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View file

@ -1,9 +1,14 @@
+ Identify what needs to be done
+ check __init__.py
+ check tests.py
+ check serve_tests.py
+ Fix unittests + Fix unittests
+ Fix exceptions when websocket server disappears + Fix exceptions when websocket server disappears
Fix thread exceptions + Fix thread exceptions
Finish creating low-level _SocketIO to eliminate cyclic references + Finish creating low-level _SocketIO to eliminate cyclic references
Move namespace and callback handling to _ListenerThread + Move namespace and callback handling to _ListenerThread
= Resolve pull requests
Resolve issues
Integrate Zac's fork #6 Integrate Zac's fork #6
Integrate Sajal's fork #7 Integrate Sajal's fork #7
Integrate Francis's fork #10 Integrate Francis's fork #10

View file

@ -1,15 +1,16 @@
import socket import socket
from anyjson import dumps, loads from anyjson import dumps, loads
from threading import Event, Thread from threading import Thread, Event
from time import sleep from time import sleep
from urllib import urlopen from urllib import urlopen
from websocket import WebSocketConnectionClosedException, create_connection from websocket import WebSocketConnectionClosedException, create_connection
PROTOCOL = 1 # SocketIO protocol version PROTOCOL = 1 # socket.io protocol version
class BaseNamespace(object): # pragma: no cover class BaseNamespace(object): # pragma: no cover
'Define socket.io behavior'
def __init__(self, _socketIO): def __init__(self, _socketIO):
self._socketIO = _socketIO self._socketIO = _socketIO
@ -138,7 +139,7 @@ class _RhythmicThread(Thread):
class _ListenerThread(Thread): class _ListenerThread(Thread):
'Process messages from SocketIO server' 'Process messages from socket.io server'
daemon = True daemon = True
@ -195,7 +196,6 @@ class _ListenerThread(Thread):
get_eventCallback('connect')() get_eventCallback('connect')()
def on_heartbeat(self, packetID, get_eventCallback, data): def on_heartbeat(self, packetID, get_eventCallback, data):
# get_eventCallback('heartbeat')()
pass pass
def on_message(self, packetID, get_eventCallback, data): def on_message(self, packetID, get_eventCallback, data):
@ -207,7 +207,7 @@ class _ListenerThread(Thread):
def on_event(self, packetID, get_eventCallback, data): def on_event(self, packetID, get_eventCallback, data):
valueByName = loads(data) valueByName = loads(data)
eventName = valueByName['name'] eventName = valueByName['name']
eventArguments = valueByName['args'] eventArguments = valueByName.get('args', [])
get_eventCallback(eventName)(*eventArguments) get_eventCallback(eventName)(*eventArguments)
def on_acknowledgment(self, packetID, get_eventCallback, data): def on_acknowledgment(self, packetID, get_eventCallback, data):