Browse Source

outdoor users(16)

Louis Farina 3 years ago
parent
commit
9d55a5700e
4 changed files with 7 additions and 6 deletions
  1. BIN
      Projet.jar
  2. 4
    2
      src/chat/NetworkClient.java
  3. 0
    1
      src/chat/OutdoorListenerThread.java
  4. 3
    3
      src/chat/ReceiveThread.java

BIN
Projet.jar View File


+ 4
- 2
src/chat/NetworkClient.java View File

203
 	
203
 	
204
 	void send (Notification notif)
204
 	void send (Notification notif)
205
 	{
205
 	{
206
+		System.out.println("Indoor users:");
206
 		for(Socket s:dest_sockets)
207
 		for(Socket s:dest_sockets)
207
 		{
208
 		{
208
 			try
209
 			try
209
 			{
210
 			{
210
-				//System.out.println(s.getInetAddress().getHostAddress() + ": local port " + s.getLocalPort() + ", remote port " + s.getPort());
211
+				System.out.println(s.getInetAddress().getHostAddress() + ": local port " + s.getLocalPort() + ", remote port " + s.getPort());
211
 				ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
212
 				ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
212
 			    out.writeObject(notif);
213
 			    out.writeObject(notif);
213
 			}
214
 			}
214
 			catch(IOException e){}
215
 			catch(IOException e){}
215
 		}
216
 		}
217
+		System.out.println("Outdoor users:");
216
 		for(Socket s:outdoor_dest_sockets)
218
 		for(Socket s:outdoor_dest_sockets)
217
     	{
219
     	{
218
     		try
220
     		try
219
     		{
221
     		{
220
-    			//System.out.println(s.getInetAddress().getHostAddress() + ": local port " + s.getLocalPort() + ", remote port " + s.getPort());
222
+    			System.out.println(s.getInetAddress().getHostAddress() + ": local port " + s.getLocalPort() + ", remote port " + s.getPort());
221
     			ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
223
     			ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
222
 			    out.writeObject(notif);
224
 			    out.writeObject(notif);
223
     		}
225
     		}

+ 0
- 1
src/chat/OutdoorListenerThread.java View File

43
 		String username;
43
 		String username;
44
 		String response = "";
44
 		String response = "";
45
 		
45
 		
46
-		
47
 		try
46
 		try
48
 		{
47
 		{
49
 			while(!exit)
48
 			while(!exit)

+ 3
- 3
src/chat/ReceiveThread.java View File

47
 			        
47
 			        
48
 			        if(!(notif.getAuthor().equals(user)) && !notif.isRedirected())
48
 			        if(!(notif.getAuthor().equals(user)) && !notif.isRedirected())
49
 	            	{
49
 	            	{
50
-	            		System.out.println("Redirecting message");
51
 	            		for(Socket s:outdoor_dest_sockets)
50
 	            		for(Socket s:outdoor_dest_sockets)
52
 				    	{
51
 				    	{
53
 				    		try
52
 				    		try
55
 				    			ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
54
 				    			ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
56
 				    			notif.setRedirected(true);
55
 				    			notif.setRedirected(true);
57
 				    		    out.writeObject(notif);
56
 				    		    out.writeObject(notif);
57
+				    		    notif.setRedirected(false);
58
 				    		}
58
 				    		}
59
 				    		catch(IOException e){}
59
 				    		catch(IOException e){}
60
 				    	}
60
 				    	}
141
 		catch(EOFException e) {}
141
 		catch(EOFException e) {}
142
 		catch(SocketException e)
142
 		catch(SocketException e)
143
 		{
143
 		{
144
-            /*	if(!isOutdoor)
144
+            	if(!isOutdoor)
145
             	dest_sockets.remove(socket);
145
             	dest_sockets.remove(socket);
146
             	else
146
             	else
147
-            	outdoor_dest_sockets.remove(socket);*/
147
+            	outdoor_dest_sockets.remove(socket);
148
 		}
148
 		}
149
 		catch(Exception e)
149
 		catch(Exception e)
150
     	{
150
     	{

Loading…
Cancel
Save