############################################################################# ## This file is part of TunnelHack II. ## ##-------------------------------------------------------------------------## ## Copyright 2007-2008 Bryce Schroeder ## ## bryce.schroeder@gmail.com ## ## http://www.ferazelhosting.net/~bryce/ ## ##-------------------------------------------------------------------------## ## This program is free software: you can redistribute it and/or modify ## ## it under the terms of the GNU General Public License as published by ## ## the Free Software Foundation, either version 3 of the License, or ## ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## ## along with this program. If not, see . ## ############################################################################# from __future__ import absolute_import import os, signal, random, time import net, db from g import g ############################################################################## # Doing UNIX stuff (setting up signals, etc) # ############################################################################## def handle_SIGHUP(signal, frame): # synchronize the database to disk. g.db.sync() ############################################################################## # Do network stuff # ############################################################################## class TestHandler(net.NetHandler): def new_client(self, name): print "**", name, "joined" def dropped_client(self, name): print "!!", name, "dropped" nw = net.Net(31337) nw.attach_handler(TestHandler()) laila_x = 5 laila_y = 5 counter = 0 while 1: counter += 1 #nw.mailcarrier() nw.process() #for msg in nw.fetch(): # print "SERVER:", msg if not counter % 100000: msg = net.MsgEdgeProp(name='default', edge=random.choice(EDGES)) nw.emit(msg, '*')