quakeball/Assets/Scripts/Net/Peers/Client.cs
2020-08-02 21:32:30 +03:00

27 lines
791 B
C#

using System.Collections.Generic;
using UnityEngine;
using System;
using System.Net.Sockets;
using System.Text;
using System.Net;
namespace NeonTea.Quakeball.Net.Peers {
public class Client : Peer {
public override void OnStart(string host, int port) {
SendBytes(Encoding.UTF8.GetBytes("Hello! This is testing."), MainConnection.Endpoint);
Debug.Log($"Client started at {host}:{port}!");
}
public override void HandlePacket(IPEndPoint endpoint, ByteReader reader) {
if (endpoint.Equals(MainConnection.Endpoint)) {
Debug.Log("Got stuff!");
}
}
public override void OnStop(DisconnectReason reason) {
Debug.Log($"Client closed: {reason.Description}");
}
}
}