Last active
February 12, 2018 10:02
-
-
Save korkmazkadir/7cdea3be7ac7d3e3f00ecdc6cfe65485 to your computer and use it in GitHub Desktop.
Client uygulaması main metod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package simplechat; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.rmi.NotBoundException; | |
import java.rmi.RemoteException; | |
import java.rmi.registry.LocateRegistry; | |
import java.rmi.registry.Registry; | |
import java.rmi.server.UnicastRemoteObject; | |
import java.util.Set; | |
import simplechat.common.ChatClient; | |
import simplechat.common.ChatServer; | |
import simplechat.common.Client; | |
/** | |
* | |
* @author Kadir Korkmaz | |
*/ | |
public class ClientApp { | |
private static ChatServer chatServer; | |
private static Client client; | |
private static ChatClient clientStub; | |
public static void main(String[] args) throws RemoteException, NotBoundException, IOException { | |
String username = "Kadir"; | |
String serverAddress = "localhost"; | |
Registry registry = LocateRegistry.getRegistry(serverAddress, 2020); | |
if (registry == null) { | |
System.err.println("Error : Registry is null :(. Did you run a server"); | |
return; | |
} | |
client = new Client(username); | |
clientStub = (ChatClient) UnicastRemoteObject.exportObject(client, 0); | |
chatServer = (ChatServer) registry.lookup("ChatServerObject"); | |
String[] currentUsers = chatServer.registerClient(clientStub); | |
client.addCurrentUsers(currentUsers); | |
System.out.println("Connected to server..."); | |
handleUserRequests(); | |
} | |
...... | |
..... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment