1
0
Fork 0
This repository has been archived on 2024-01-06. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
First-2D-Game-UDP/src/mrdev023/network/packet/PingClientPacket.java
2016-09-17 18:09:21 +02:00

38 lines
771 B
Java

package mrdev023.network.packet;
import java.net.*;
import mrdev023.gameengine.*;
import mrdev023.network.common.*;
import mrdev023.network.packet.main.*;
public class PingClientPacket implements IPacket{
public long current;
public PingClientPacket(){
}
public PingClientPacket(long current){
this.current = current;
}
public void write(DataBuffer buff) throws Exception {
buff.put(current);
}
public void read(DataBuffer buff) throws Exception {
this.current = buff.getLong();
}
public void manage(Client client, IPacket packet) throws Exception {
GameEngine.setPing((System.currentTimeMillis() - current));
}
public void manage(Client client, IPacket packet, DatagramSocket server) throws Exception {
client.send(packet);
}
}