[Javanetsim-cvs] javaNetSim/core WANRMICallback.java, NONE, 1.1 WANRMIClient.java, NONE, 1.1 WANDat
Status: Beta
Brought to you by:
darkkey
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv18458/core Modified Files: WANDatagram.java WANNetworkInterface.java WANRMI.java WANRMIServer.java WANSocket.java Added Files: WANRMICallback.java WANRMIClient.java Log Message: few fixes of WANs Index: WANRMIServer.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANRMIServer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WANRMIServer.java 10 Nov 2007 13:25:38 -0000 1.2 --- WANRMIServer.java 27 Nov 2007 16:56:27 -0000 1.3 *************** *** 24,29 **** } ! public void setServiceName(String inService) throws RemoteException{ ! parentInterface.setConnService(inService); //parentInterface.connect(); } --- 24,29 ---- } ! public void setServiceName(WANRMICallback callback) throws RemoteException{ ! parentInterface.setRMICallback(callback); //parentInterface.connect(); } --- NEW FILE: WANRMIClient.java --- (This appears to be a binary file; contents omitted.) Index: WANRMI.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANRMI.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WANRMI.java 10 Nov 2007 13:25:38 -0000 1.2 --- WANRMI.java 27 Nov 2007 16:56:27 -0000 1.3 *************** *** 18,21 **** public void recievePacket(String inPacket) throws RemoteException; ! public void setServiceName(String inService) throws RemoteException; } --- 18,21 ---- public void recievePacket(String inPacket) throws RemoteException; ! public void setServiceName(WANRMICallback callback) throws RemoteException; } --- NEW FILE: WANRMICallback.java --- (This appears to be a binary file; contents omitted.) Index: WANSocket.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANSocket.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** WANSocket.java 19 Nov 2007 15:10:28 -0000 1.5 --- WANSocket.java 27 Nov 2007 16:56:27 -0000 1.6 *************** *** 124,127 **** --- 124,128 ---- public void run() { try{ + while(s != null){ Socket incoming = s.accept(); parentInterface.addLayerInfo("Wan interface", "Accepted connection from peer."); *************** *** 140,144 **** incoming.close(); incoming = null; ! w.setClientSocket(null, null); }catch(Exception e){ parentInterface.addLayerInfo("Wan interface", "Error during communication: " + e.toString()); --- 141,146 ---- incoming.close(); incoming = null; ! w.setClientSocket(null, null); ! } }catch(Exception e){ parentInterface.addLayerInfo("Wan interface", "Error during communication: " + e.toString()); Index: WANNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANNetworkInterface.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** WANNetworkInterface.java 20 Nov 2007 19:17:09 -0000 1.8 --- WANNetworkInterface.java 27 Nov 2007 16:56:27 -0000 1.9 *************** *** 56,59 **** --- 56,61 ---- protected WANRMIServer RMIServer; protected WANRMI RMIClient; + protected WANRMICallback RMICallback; + protected WANRMIClient RMIClientCallback; protected WANCorbaServer CORBAServer; *************** *** 105,108 **** --- 107,114 ---- } + public void setRMICallback(WANRMICallback callback){ + this.RMICallback = callback; + } + /* /Interface properties setup functions */ *************** *** 143,146 **** --- 149,153 ---- Service = ""; Host = ""; + RMICallback = null; if (System.getSecurityManager() == null) System.setSecurityManager ( new RMISecurityManager() ); *************** *** 226,231 **** try{ switch(type){ ! case RMI: ! RMIClient.recievePacket(inPacket.toBytes()); break; case SocketUDP: --- 233,241 ---- try{ switch(type){ ! case RMI: ! if(server) ! RMICallback.recievePacket(inPacket.toBytes()); ! else ! RMIClient.recievePacket(inPacket.toBytes()); break; case SocketUDP: *************** *** 315,319 **** RMIClient = (WANRMI) Naming.lookup ("rmi://" + Host + ":" + port + "/" + Service); ! RMIClient.setServiceName(name); connected = true; --- 325,331 ---- RMIClient = (WANRMI) Naming.lookup ("rmi://" + Host + ":" + port + "/" + Service); ! RMIClientCallback = null; ! RMIClientCallback = new WANRMIClient(this); ! RMIClient.setServiceName( RMIClientCallback ); connected = true; *************** *** 364,370 **** switch(type){ case RMI: RMIClient = null; Naming.unbind(name); ! RMIServer = null; break; case Corba: --- 376,384 ---- switch(type){ case RMI: + RMIClientCallback = null; + RMICallback = null; RMIClient = null; Naming.unbind(name); ! RMIServer = null; break; case Corba: Index: WANDatagram.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WANDatagram.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WANDatagram.java 20 Nov 2007 19:17:09 -0000 1.2 --- WANDatagram.java 27 Nov 2007 16:56:27 -0000 1.3 *************** *** 49,53 **** }else{ s = new DatagramSocket(); ! sendPacket("P#"); } --- 49,53 ---- }else{ s = new DatagramSocket(); ! sendPacket("P!#"); } *************** *** 114,117 **** --- 114,118 ---- WANDatagram w; WANNetworkInterface parentInterface; + boolean occupied; private InputStream in; *************** *** 124,127 **** --- 125,129 ---- this.w = w; this.parentInterface = parentInterface; + occupied = false; } *************** *** 137,141 **** s.receive(packet); ! setClientAddress(packet.getAddress().getHostAddress(), packet.getPort()); w.recievePacket((new String(packet.getData(),"ascii")).substring(0, packet.getLength())); --- 139,146 ---- s.receive(packet); ! if((new String(packet.getData(),"ascii")).contains("P!#") && !occupied){ ! setClientAddress(packet.getAddress().getHostAddress(), packet.getPort()); ! occupied = true; ! } w.recievePacket((new String(packet.getData(),"ascii")).substring(0, packet.getLength())); |