예제 #1
0
 private void StartServer()
 {
     lanBc.StopBroadcasting();
     lanBc.StartAnnounceBroadcasting();
     udpHandler = new UdpHandler(portGameServer);
     udpHandler.StartListening();
     role = PlayerRole.Server;
     Debug.Log("Starting Server -> " + udpHandler.SessionId);
 }
예제 #2
0
        private void ConnectToServer(string ip)
        {
            Debug.Log("Connecting to server: " + ip);
            lanBc.StopBroadcasting();
            udpHandler = new UdpHandler(portGameClient);
            udpHandler.StartListening();
            destAddr = new IPEndPoint(IPAddress.Parse(ip), portGameServer);
            var command = new CommandConnect();

            udpHandler.SendMessage(new UdpMessage(destAddr, command));
            role = PlayerRole.Client;
        }
예제 #3
0
 public UdpMessage(IPEndPoint remote, Command cmd, UdpHandler udpHandler = null)
 {
     this.remote     = remote;
     this.cmd        = cmd;
     this.udpHandler = udpHandler;
 }
예제 #4
0
 public UdpMessage(IPEndPoint remote, byte[] data, UdpHandler udpHandler = null)
 {
     this.remote     = remote;
     this.cmd        = Command.Create(data);
     this.udpHandler = udpHandler;
 }