[lobby-svn] SF.net SVN: lobby: [275] trunk/src/org/lobby/server
Brought to you by:
yuranet
From: <air...@us...> - 2007-07-29 05:04:53
|
Revision: 275 http://lobby.svn.sourceforge.net/lobby/?rev=275&view=rev Author: airpizza Date: 2007-07-28 22:04:52 -0700 (Sat, 28 Jul 2007) Log Message: ----------- Forgot to commit the server. Modified Paths: -------------- trunk/src/org/lobby/server/ChatRoom.java trunk/src/org/lobby/server/ClientPool.java trunk/src/org/lobby/server/DisconnectedSession.java trunk/src/org/lobby/server/DynamicURLClassLoader.java trunk/src/org/lobby/server/GameRoom.java trunk/src/org/lobby/server/GameType.java trunk/src/org/lobby/server/GenericDatabase.java trunk/src/org/lobby/server/HostGameLobby.java trunk/src/org/lobby/server/InvalidConfigurationException.java trunk/src/org/lobby/server/InvalidDatabaseException.java trunk/src/org/lobby/server/InvalidLoginException.java trunk/src/org/lobby/server/LobbyServer.java trunk/src/org/lobby/server/MainRoom.java trunk/src/org/lobby/server/MemoryDatabase.java trunk/src/org/lobby/server/MySQLDatabase.java trunk/src/org/lobby/server/Protocol.java trunk/src/org/lobby/server/RoomID.java trunk/src/org/lobby/server/ServerGame.java trunk/src/org/lobby/server/ServerGameListener.java trunk/src/org/lobby/server/ServerSecurityManager.java trunk/src/org/lobby/server/Session.java trunk/src/org/lobby/server/UtilityBelt.java Modified: trunk/src/org/lobby/server/ChatRoom.java =================================================================== --- trunk/src/org/lobby/server/ChatRoom.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/ChatRoom.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; import java.util.UUID; Modified: trunk/src/org/lobby/server/ClientPool.java =================================================================== --- trunk/src/org/lobby/server/ClientPool.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/ClientPool.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -294,12 +294,15 @@ } private void gameObject(byte[] message,UUID uuid) { - HashMap<String,byte[]> fields= getFields(message); try { - ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(fields.get(Protocol.FIELD_MESSAGE_STR))); + int gameIDLen = UtilityBelt.byteArrayToInt(new byte[]{message[0],message[1],message[2],message[3]}); + byte[] objectByteArray = new byte[message.length-gameIDLen-4];//4bytes for the length and whatever len the gameID is + byte[] gameID = new byte[gameIDLen]; + System.arraycopy(message,4+gameID.length,objectByteArray,0,objectByteArray.length); + System.arraycopy(message,4,gameID,0,gameID.length); + ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(objectByteArray)); Object object = ois.readObject(); - String gameID = new String(fields.get(Protocol.FIELD_ID_STR)); Session session = userList.get(uuid); GameRoom gl = GameRoom.byRoomID(new RoomID(gameID)); if(session.isPlaying(gl)) Modified: trunk/src/org/lobby/server/DisconnectedSession.java =================================================================== --- trunk/src/org/lobby/server/DisconnectedSession.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/DisconnectedSession.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; import java.util.UUID; Modified: trunk/src/org/lobby/server/DynamicURLClassLoader.java =================================================================== --- trunk/src/org/lobby/server/DynamicURLClassLoader.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/DynamicURLClassLoader.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; import java.net.URL; import java.net.URLClassLoader; Modified: trunk/src/org/lobby/server/GameRoom.java =================================================================== --- trunk/src/org/lobby/server/GameRoom.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/GameRoom.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; import java.util.UUID; import java.util.Vector; Modified: trunk/src/org/lobby/server/GameType.java =================================================================== --- trunk/src/org/lobby/server/GameType.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/GameType.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; import java.util.Collection; import java.util.Collections; Modified: trunk/src/org/lobby/server/GenericDatabase.java =================================================================== --- trunk/src/org/lobby/server/GenericDatabase.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/GenericDatabase.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; interface GenericDatabase { Modified: trunk/src/org/lobby/server/HostGameLobby.java =================================================================== --- trunk/src/org/lobby/server/HostGameLobby.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/HostGameLobby.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; import java.util.UUID; public class HostGameLobby extends GameRoom { Modified: trunk/src/org/lobby/server/InvalidConfigurationException.java =================================================================== --- trunk/src/org/lobby/server/InvalidConfigurationException.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/InvalidConfigurationException.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; public class InvalidConfigurationException extends Exception { Modified: trunk/src/org/lobby/server/InvalidDatabaseException.java =================================================================== --- trunk/src/org/lobby/server/InvalidDatabaseException.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/InvalidDatabaseException.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; public class InvalidDatabaseException extends Exception { Modified: trunk/src/org/lobby/server/InvalidLoginException.java =================================================================== --- trunk/src/org/lobby/server/InvalidLoginException.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/InvalidLoginException.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; public class InvalidLoginException extends Exception { Modified: trunk/src/org/lobby/server/LobbyServer.java =================================================================== --- trunk/src/org/lobby/server/LobbyServer.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/LobbyServer.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; import java.util.Properties; import java.io.IOException; @@ -84,7 +84,7 @@ } catch (IOException io) { - LobbyServer.log("Error writing out default configuration file"); + System.err.println("Error writing out default configuration file"); io.printStackTrace(); } } @@ -229,10 +229,13 @@ */ static void log(String message,Level level) { - System.out.println(">>>>>>>>>>>>>>>>>"); - - logger.log(level,message); - System.out.println("<<<<<<<<<<<<<<<<<"); + if(logger.getLevel().intValue()<level.intValue()) + { + System.out.println(">>>>>>>>>>>>>>>>>"); + + logger.log(level,message); + System.out.println("<<<<<<<<<<<<<<<<<"); + } } static void log(String message) { @@ -270,15 +273,8 @@ */ void newMainLobby(String lobbyName) { - try - { - MainRoom newLobby = new MainRoom(lobbyName,new RoomID(UUID.randomUUID().toString().getBytes()),this); - updateMainRooms(newLobby,1); - } - catch (Exception e) - { - log("ERROR IN: NEW MAIN LOBBY",Level.WARNING); - } + MainRoom newLobby = new MainRoom(lobbyName,new RoomID(UUID.randomUUID().toString().getBytes()),this); + updateMainRooms(newLobby,1); } /** * Creates a new user around the given socket channel. @@ -287,12 +283,12 @@ */ void newUser(SocketChannel sc) { - LobbyServer.log("adding new user"); - UUID userUUID = UUID.randomUUID(); - ClientPool llCP = leastLoadedCP(); - llCP.register(new Session(sc,userUUID,llCP)); + LobbyServer.log("adding new user"); + UUID userUUID = UUID.randomUUID(); + ClientPool llCP = leastLoadedCP(); + llCP.register(new Session(sc,userUUID,llCP)); } - /** + /** * Is called after the new user is registered with a client pool * Sends the motd, public key, game types and main rooms to the client. * @param newSession @@ -376,7 +372,7 @@ } void sendGameObject(RoomID gameID,byte[] object,Session session) { - session.cp.send(Protocol.gameObject,UtilityBelt.formatGameMessage(object,gameID),session.uuid); + session.cp.send(Protocol.gameObject,UtilityBelt.formatGameObject(object,gameID),session.uuid); } /** Modified: trunk/src/org/lobby/server/MainRoom.java =================================================================== --- trunk/src/org/lobby/server/MainRoom.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/MainRoom.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; import java.util.UUID; import java.util.Vector; Modified: trunk/src/org/lobby/server/MemoryDatabase.java =================================================================== --- trunk/src/org/lobby/server/MemoryDatabase.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/MemoryDatabase.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; import java.net.MalformedURLException; import java.net.URL; Modified: trunk/src/org/lobby/server/MySQLDatabase.java =================================================================== --- trunk/src/org/lobby/server/MySQLDatabase.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/MySQLDatabase.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; import java.util.Calendar; import java.net.URL; import java.util.logging.Level; Modified: trunk/src/org/lobby/server/Protocol.java =================================================================== --- trunk/src/org/lobby/server/Protocol.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/Protocol.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,5 +1,5 @@ -package org.lobby.server; +package dev.server; /** * @author Mike Chaten Modified: trunk/src/org/lobby/server/RoomID.java =================================================================== --- trunk/src/org/lobby/server/RoomID.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/RoomID.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; public class RoomID { Modified: trunk/src/org/lobby/server/ServerGame.java =================================================================== --- trunk/src/org/lobby/server/ServerGame.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/ServerGame.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; public interface ServerGame { Modified: trunk/src/org/lobby/server/ServerGameListener.java =================================================================== --- trunk/src/org/lobby/server/ServerGameListener.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/ServerGameListener.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; import java.io.Serializable; public interface ServerGameListener { Modified: trunk/src/org/lobby/server/ServerSecurityManager.java =================================================================== --- trunk/src/org/lobby/server/ServerSecurityManager.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/ServerSecurityManager.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; public class ServerSecurityManager extends SecurityManager { Modified: trunk/src/org/lobby/server/Session.java =================================================================== --- trunk/src/org/lobby/server/Session.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/Session.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,4 +1,4 @@ -package org.lobby.server; +package dev.server; import java.nio.channels.SocketChannel; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; Modified: trunk/src/org/lobby/server/UtilityBelt.java =================================================================== --- trunk/src/org/lobby/server/UtilityBelt.java 2007-07-29 05:03:03 UTC (rev 274) +++ trunk/src/org/lobby/server/UtilityBelt.java 2007-07-29 05:04:52 UTC (rev 275) @@ -1,5 +1,5 @@ -package org.lobby.server; +package dev.server; import java.security.KeyPair; import java.security.KeyPairGenerator; @@ -281,6 +281,12 @@ byte[] messageField = joinField(Protocol.FIELD_MESSAGE,message); return joinArrays(idField,messageField); } + static byte[] formatGameObject(byte[] message,RoomID gameID) + { + byte[] id = gameID.getBytes(); + byte[] idLen = intToByteArray(id.length); + return joinArrays(idLen,id,message); + } static synchronized byte[] decrypt(byte[] message) { try This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |