Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:psubocz/garden-dWARves

  • Loading branch information...
commit 7cf8bc3ab419eb3bcf707c1305bbcdcdd6d628ee 2 parents a5ebf63 + f74738f
@lqc lqc authored
View
BIN  client/statics/images/startScreen.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
39 server/actor.py
@@ -1,5 +1,6 @@
from socketio.namespace import BaseNamespace
-
+from gevent.queue import Queue
+import gevent
UNCONNECTED = 0
CONNECTED = 1
SEARCHING = 2
@@ -10,7 +11,41 @@ class ActorProxy(BaseNamespace):
def initialize(self):
self._state = UNCONNECTED
-
+ self.incoming_queue = Queue(0)
+
+ # spawn incoming queue greenlet
+ self.spawn(self._incoming)
+ self._actor = Actor()
+ self._actor.bind_proxy(self)
+ gevent.spawn(self._actor.run)
+
+ def _incoming(self):
+ for event,args in self.incoming_queue:
+ try:
+ self.emit(event, *args)
+ except Exception, e:
+ print e
+
+ def process_event(self, packet):
+ gevent.spawn(self._actor.inbox.put, (packet['name'], packet['args']))
+
+class Actor(object):
+
+ def __init__(self):
+ self._proxy = None
+ self.inbox = Queue(0)
+
+ def bind_proxy(self, proxy):
+ self._proxy = proxy
+
+ def run(self):
+ for event,args in self.inbox:
+ fun = getattr(self, 'on_'+event)
+ fun(*args)
+
+ def emit(self, event, *args):
+ gevent.spawn(self._proxy.incoming_queue.put, (event, args))
+
def on_connect(self, udata):
self._udata = udata
self._change_state(CONNECTED)
View
5 server/server.py
@@ -22,8 +22,9 @@ def handle_src(path):
@route('/')
def handle_index():
- return static_file('index.html', root='../client/statics')
-
+ #return static_file('index.html', root='../client/statics')
+ return static_file('index.html', root='clitest/')
+
print "Starting socket.io server at %s:%d" % (config.SOCKETIO_IFACE, config.SOCKETIO_PORT)
SocketIOServer((config.SOCKETIO_IFACE, config.SOCKETIO_PORT), bottle.default_app(), namespace="socket.io").serve_forever()
Please sign in to comment.
Something went wrong with that request. Please try again.