Пример #1
0
        void Start()
        {
            Application.runInBackground = true;

            try {
                udpClient = new UdpClient();
                udpClient.Connect(hostname, port);
            } catch (Exception e) {
                Debug.Log(e.ToString());
            }

            myFullAddress = udpClient.Client.LocalEndPoint.ToString();
            Text playerText = player.GetComponentInChildren <Text> ();

            playerText.text = myFullAddress;

            Movement.OnMovement += SendPlayerMovement;

            PlayerPositionMessage connectMessage = new PlayerPositionMessage(type: "connect");

            SendToServer(connectMessage);

            udpClient.BeginReceive(new AsyncCallback(OnMessageCallback), null);
        }
Пример #2
0
 void SendPlayerMovement(PlayerPositionMessage playerPosition)
 {
     SendToServer(playerPosition);
 }