Trees | Indices | Help |
|
---|
|
1 ##################################################################### 2 # -*- coding: iso-8859-1 -*- # 3 # # 4 # Frets on Fire # 5 # Copyright (C) 2006 Sami Kyöstilä # 6 # # 7 # This program is free software; you can redistribute it and/or # 8 # modify it under the terms of the GNU General Public License # 9 # as published by the Free Software Foundation; either version 2 # 10 # of the License, or (at your option) any later version. # 11 # # 12 # This program is distributed in the hope that it will be useful, # 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of # 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 15 # GNU General Public License for more details. # 16 # # 17 # You should have received a copy of the GNU General Public License # 18 # along with this program; if not, write to the Free Software # 19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # 20 # MA 02110-1301, USA. # 21 ##################################################################### 22 23 import Network 24 import Engine 25 import Log 26 import cPickle as pickle 27 28 from Session import ServerSession, MessageBroker 29 from World import WorldServer 307433 Network.Server.__init__(self) 34 self.engine = engine 35 self.sessions = {} 36 self.broker = MessageBroker() 37 self.world = WorldServer(self.engine, server = self) 38 self.broker.addMessageHandler(self.world)3941 return ServerSession(self.engine, sock)4244 Log.debug("Session #%d connected." % conn.id) 45 self.sessions[conn.id] = conn 46 self.engine.addTask(conn, synchronized = False)4749 Network.Server.handleConnectionClose(self, conn) 50 self.engine.removeTask(conn) 51 try: 52 del self.sessions[conn.id] 53 except KeyError: 54 pass5557 for id, session in self.sessions.items(): 58 if id in ignore: continue 59 session.sendMessage(message) 60 if meToo: 61 session.handleMessage(0, message)6264 try: 65 self.sessions[receiverId].sendMessage(message) 66 except IndexError: 67 Log.warning("Tried to send message to nonexistent session #%d." % receiverId)68 7173 self.close()
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Sat Oct 20 15:25:09 2007 | http://epydoc.sourceforge.net |