Package com.golden.gamedev.engine.network.packet

Examples of com.golden.gamedev.engine.network.packet.NetworkMessage


      packet = NetworkPing.getInstance();
     
    }
    else {
      // network packet
      packet = (packetID == NetworkMessage.ID) ? new NetworkMessage()
              : this.createPacket(packetID);
     
      // decompress
      if (packet.isCompressed()) {
        input = this.decompress(input);
View Full Code Here


      for (int i = 0; i < clients.length; i++) {
        System.out.println("New Client Connected: "
                + clients[i].getRemoteDetail());
       
        try {
          clients[i].sendPacket(new NetworkMessage("Hello World"));
         
        }
        catch (IOException ex) {
          ex.printStackTrace();
        }
      }
    }
   
    // handle disconnected clients
    clients = server.getDisconnectedClients(); // all disconnected clients
    if (clients.length > 0) {
      System.out.println("DISCONNECTED CLIENT = " + clients.length);
    }
   
    for (int i = 0; i < clients.length; i++) {
      System.out.println("Client Disconnected: "
              + clients[i].getRemoteDetail());
    }
   
    // handle new packets
    clients = server.getReceivedPacketClients(); // all clients which
                            // received packets
    for (int i = 0; i < clients.length; i++) {
      NetworkPacket[] packets = clients[i].getReceivedPackets(); // get
                                    // the
                                    // packets
     
      for (int j = 0; j < packets.length; j++) {
        NetworkMessage packet = (NetworkMessage) packets[j];
       
        System.out.println(clients[i].getRemoteDetail() + ": "
                + packet.getMessage());
       
        try {
          clients[i].sendPacket(new NetworkMessage("Server said OK"));
         
        }
        catch (IOException ex) {
          ex.printStackTrace();
        }
View Full Code Here

      }
     
      // handle received messages
      NetworkPacket[] packets = client.getReceivedPackets();
      for (int j = 0; j < packets.length; j++) {
        NetworkMessage packet = (NetworkMessage) packets[j];
       
        System.out.println(client.getRemoteDetail() + ": "
                + packet.getMessage());
      }
     
      // send message
      // every 20 tick
      if (i++ % 20 == 0 && i < 100) {
        try {
          System.out.println("sending packet to server");
          client.sendPacket(new NetworkMessage(
                  "Client said Yes or No"));
         
        }
        catch (IOException ex) {
          ex.printStackTrace();
View Full Code Here

        this.client.update(100);
       
        NetworkPacket[] receivedPackets = this.client
                .getReceivedPackets();
        for (int i = 0; i < receivedPackets.length; i++) {
          NetworkMessage packet = (NetworkMessage) receivedPackets[i];
         
          this.appendText(packet.getMessage() + "\n");
        }
       
        try {
          Thread.sleep(100);
         
View Full Code Here

    if (message.length() == 0) {
      return;
    }
   
    try {
      this.client.sendPacket(new NetworkMessage(message));
     
      message = this.nick + ": " + message;
     
      this.txtMessage.selectAll();
     
View Full Code Here

        String nick = (String) clients[i].getInfo();
        String message = "> " + nick + " left.";
        this.listOnline.removeElement(nick);
       
        try {
          this.server.broadcastPacket(new NetworkMessage(message));
         
          this.appendText(message + "\n");
         
        }
        catch (Exception ex) {
          ex.printStackTrace();
        }
      }
     
      // handle new message
      clients = this.server.getReceivedPacketClients();
      for (int i = 0; i < clients.length; i++) {
        NetworkPacket[] receivedPackets = clients[i]
                .getReceivedPackets();
       
        for (int j = 0; j < receivedPackets.length; j++) {
          NetworkMessage packet = (NetworkMessage) receivedPackets[j];
         
          // handle login client
          if (clients[i].isGroupName("LOGIN")) {
            this.handleLoginClient(clients[i], packet);
           
View Full Code Here

    this.listOnline.addElement(nick);
   
    try {
      String message = "> " + nick + " joined.";
     
      this.server.broadcastPacket(new NetworkMessage(message), client);
      this.appendText(message + "\n");
     
    }
    catch (IOException ex) {
      ex.printStackTrace();
View Full Code Here

 
  private void handleChatClient(BaseClient client, NetworkMessage packet) {
    try {
      String message = client.getInfo() + ": " + packet.getMessage();
     
      this.server.broadcastPacket(new NetworkMessage(message), client);
      this.appendText(message + "\n");
     
    }
    catch (IOException ex) {
      ex.printStackTrace();
View Full Code Here

    }
   
    message = "> " + message;
   
    try {
      this.server.broadcastPacket(new NetworkMessage(message));
     
      this.txtMessage.selectAll();
      this.txaChat.append(message + "\n");
    }
    catch (IOException ex) {
View Full Code Here

      System.exit(0);
    }
   
    // send the client nick name
    try {
      client.sendPacket(new NetworkMessage(nick));
    }
    catch (IOException ex) {
      ex.printStackTrace();
     
      JOptionPane.showMessageDialog(null, "Connection Failed.\n"
View Full Code Here

TOP

Related Classes of com.golden.gamedev.engine.network.packet.NetworkMessage

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.