You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
868 B

5 years ago
using Godot;
using System.Threading;
public class Server : Peer {
private static PacketPeerUDP PacketPeer;
private byte[] TempBuffer = { 1 };
5 years ago
public Server(PacketPeerUDP packetPeer) : base(packetPeer) {
PacketPeer = packetPeer;
}
public override void Initialize(string address, int port) {
StartListening(port, address);
5 years ago
GD.print("Server initialization finished.");
GD.print("Started server on " + address + ":" + port);
5 years ago
}
public override void ReceivePacket(byte[] buffer, string address, int port) {
GD.print("Server received stuff from " + address + " : " + port + " :");
for (int i = 0; i < buffer.Length; i++) {
GD.print(buffer[i]);
}
SendBuffer(TempBuffer, new Connection(address, port));
5 years ago
}
public override void Update(float delta) {
5 years ago
}
}