Package pdp.scrabble.multiplayer

Examples of pdp.scrabble.multiplayer.Server


    public void tearDown() {
    }

    @Test
    public void ServerTester() throws RemoteException {
  Server server = FACTORY.createServer(1099, LANG);
  Client client = FACTORY.createClient(null, "test");

  //Connect client to server
  try {
      server.connect(null, client);
      System.out.println("Connect client to server");
  }
  catch (RemoteException ex) {
      fail("RemoteException was not expected");
  }
  catch (NullPointerException ex) {
      System.out.println("Can't connect");
  }

  //Disconnect client
  try {
      server.disconnect(0);
      System.out.println("Disconnecting client");
  }
  catch (RemoteException ex) {
      fail("RemoteException was not expected");
  }

  //Try to connect null Client
  try {
      server.connect(null, null);
  }
  catch (RemoteException ex) {
      fail("RemoteException was not expected");
  }
  catch (NullPointerException ex) {
      System.out.println("Can't connect null client");
  }

  //Change player turn with no clients
  try {
      server.endTurnMulti();
      fail("Change turn with null client was not expected");
  }
  catch (NullPointerException ex){
      System.out.println("Can't change turn with null client");
  }
 
  // End existing server
  try {
      server.endServer();
      System.out.println("Ending server");
  }
  catch (MalformedURLException ex) {
      fail("MalformedURLException xas not expected");
  }

  //try to end server already ended
  try {
      server.endServer();
      fail("Can't end a null server");
  }
  catch (MalformedURLException ex) {
      fail("MalformedURLException not expected");
  }
View Full Code Here


  catch (RemoteException ex) {
      fail("RemoteException not expected");
  }

  // Test with server
  Server server = FACTORY.createServer(1099, LANG);
  try {
      client.connect(null, "localhost", "1099", "test", LANG);
      System.out.println("Connect to localhost on port 1099");
  }
  catch (RemoteException ex) {
      fail("RemoteException was not expected");
  }
  catch (NotBoundException ex) {
      fail("NotBoundException was not expected");
  }
  catch (MalformedURLException ex) {
      fail("MalformedURLException was not expected");
  }

  // Connect with bad adress
  try {
      client.connect(null, "test", "1099", "test", LANG);
      fail("Connect to bad address not expected");
  }
  catch (RemoteException ex) {
      System.out.println("Can't connect to bad address");
  }
  catch (NotBoundException ex) {
      fail("NotBoundException was not expected");
  }
  catch (MalformedURLException ex) {
      fail("MalformedURLException was not expected");
  }

  // Connect with bad port
  try {
      client.connect(null, "localhost", "22", "test", LANG);
      fail("Connect to localhost on port 22 not expected");
  }
  catch (RemoteException ex) {
      System.out.println("Can't connect on port 22");
  }
  catch (NotBoundException ex) {
      fail("NotBoundException was not expected");
  }
  catch (MalformedURLException ex) {
      fail("MalformedURLException was not expected");
  }

  //50 connections/disconnections
  System.out.println("50 Connections/disconnections...");
  for (int i = 0; i < 50; i++) {
      try {
    client.connect(null, "localhost", "1099", "test" + i, LANG);
    server.disconnect(0);
      }
      catch (RemoteException ex) {
    fail("RemoteException was not expected");
      }
      catch (NotBoundException ex) {
View Full Code Here

    }

    // Anagrams
    if (this.game.dictionary().contains(tmp)) {
        String str = tmp.toString();
        Server server = this.mainFrame.getMultiplayerPanel().getAction().server();
        int value = 0;

        if (server != null) {
      try {
          value = server.getWordValueServer(str);
      }
      catch (RemoteException ex) {
          Display.error("Multiplayer",
            "Unable to reach Server's bag !");
      }
View Full Code Here

    // Player which handle the server is also a client to its server

    this.client = FACTORY.createClient(this.mainFrame, this.player.getName());

    // Check connection
    Server result = this.client.connect(
        this.mainFrame, host, port, this.player.getName(),
        this.game.getLanguage());

    if (result == null) {
      Display.error("Server Unreachable", "Connection error");
View Full Code Here

TOP

Related Classes of pdp.scrabble.multiplayer.Server

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.