Esempio n. 1
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            int rowIndex;
            int colIndex;

            if (int.TryParse(txtRow.Text, out rowIndex) && int.TryParse(txtCol.Text, out colIndex))
            {
                udp.Send((rowIndex << 16) | colIndex);
            }
        }
Esempio n. 2
0
    public void SendPlayerData()
    {
        string keysPressed = "";

        for (int i = 33; i <= 122; i++)
        {
            if (Input.GetKey(((char)i).ToString().ToLower() + ""))
            {
                string input = ((char)i).ToString().ToLower();
                if (!keysPressed.Contains(input))
                {
                    keysPressed += input;
                }
            }
        }
        if (Input.GetKey(KeyCode.Space))
        {
            keysPressed += " ";
        }

        string clientData = DataParserAndFormatter.GetClientInputFormatted(keysPressed, Input.GetMouseButtonDown(0), Input.GetMouseButtonDown(1), player.transform.rotation, camera.transform.rotation, camera.transform.position, UDP.GetLocalIPAddress());

        udp.Send(clientData, serverIP); //send position and orientation and ipaddr of client to server for update
    }
Esempio n. 3
0
    // Use this for initialization
    void Start()
    {
        if (readFromFile)
        {
            server_ipaddr = System.IO.File.ReadAllText("ipAddr.txt");
        }
        udp       = new UDP(15001);
        udpListen = new UDP(15000);
        udp.StartUDP();
        udpListen.StartUDP();

        UnityHandler.player = playerPosition;

        client = new Client(server_ipaddr, playerRotation, cam, udp, udpListen);
        udp.Send(UDP.GetLocalIPAddress().ToString(), server_ipaddr);
    }
Esempio n. 4
0
        private async void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(this.rtbSend.Text))
                {
                    return;
                }
                var sendstr = this.rtbSend.Text;
                var res     = await Task.Run(() => { return(udp.Send(sendstr, Remoteip)); });

                ShowSendmsg(sendstr, res);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                this.rtbSend.Clear();
                this.rtbSend.Select();
            }
        }
Esempio n. 5
0
        public void Send(IEndPoint endPoint, byte[] packet, int length)
        {
            var nanoEndPoint = (NanoEndPoint)endPoint;

            UDP.Send(socket, ref nanoEndPoint.address, packet, length);
        }