Advertisement
Guest User

ServerImpl.java

a guest
Nov 11th, 2014
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. package com.rmicallback.server;
  2.  
  3. import com.rmicallback.client.ClientInterface;
  4. import java.rmi.RemoteException;
  5. import java.rmi.server.UnicastRemoteObject;
  6. import java.util.ArrayList;
  7. import java.util.List;
  8.  
  9. public class ServerImpl extends UnicastRemoteObject implements ServerInterface{
  10.  
  11.     private List<ClientInterface> clients = new ArrayList();
  12.    
  13.     public ServerImpl() throws RemoteException{
  14.         super();
  15.     }
  16.    
  17.     @Override
  18.     public int setClientInterface(ClientInterface cli) throws RemoteException{
  19.         clients.add(cli);
  20.         return clients.indexOf(cli);
  21.     }
  22.  
  23.     @Override
  24.     public void action(int value) throws RemoteException {
  25.         System.out.println("ACTION!");
  26.         clients.get(value).notifyMe();
  27.         System.out.println("N VALUE IS : "+clients.get(value).getN());
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement