changeset 831:889882a2798b

Small code cleanup.
author Martin Geisler <mg@daimi.au.dk>
date Sun, 13 Jul 2008 23:58:53 +0200
parents a7fba43c2c6a
children dc276dba4113
files viff/runtime.py
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/viff/runtime.py	Sun Jul 13 23:38:22 2008 +0200
+++ b/viff/runtime.py	Sun Jul 13 23:58:53 2008 +0200
@@ -1534,18 +1534,18 @@
                 return self.ctx
 
         ctx_factory = SSLContextFactory(id)
-        runtime.port = reactor.listenSSL(players[id].port, factory, ctx_factory)
+        listen = lambda port: reactor.listenSSL(port, factory, ctx_factory)
+        connect = lambda host, port: reactor.connectSSL(host, port, factory, ctx_factory)
     else:
         print "Not using SSL"
-        runtime.port = reactor.listenTCP(players[id].port, factory)
+        listen = lambda port: reactor.listenTCP(port, factory)
+        connect = lambda host, port: reactor.connectTCP(host, port, factory)
 
+    runtime.port = listen(players[id].port)
     for peer_id, player in players.iteritems():
         if peer_id > id:
             print "Will connect to %s" % player
-            if options and options.ssl:
-                reactor.connectSSL(player.host, player.port, factory, ctx_factory)
-            else:
-                reactor.connectTCP(player.host, player.port, factory)
+            connect(player.host, player.port)
 
     return result