Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - pickumater

Pages: [1]
1
General / Re: Text input
« on: August 20, 2013, 01:02:25 pm »
Thank you Laurent, I got it fixed, that code  wasn't in the event loop. : )

2
General / Text input
« on: August 20, 2013, 12:25:21 pm »
Hello, I'm having a problem with inputting text. I saw on the forums that this is one way
of doing it:

 if (event.type == sf::Event::TextEntered){
                                         if(StringPort.length()<5){
                                                 StringPort+=static_cast<char>(event.text.unicode);Sleep(150);}
                          VnesenPort.setString(StringPort);
                                                   if(event.text.unicode==8)
                                                        StringPort.erase();
 

But that doesn't work so good, because whenever I type something in, the program types it too fast, so I'm using the Sleep function, but there is obviously a better way. Please help me out : )

3
Network / Re: UDP simple functions
« on: August 17, 2013, 10:41:38 am »
I set it to 1 and it worked, thank you very much! : )

4
Network / UDP simple functions
« on: August 17, 2013, 02:25:22 am »
Hello, newbie here, I'm having a problem with udp socket receiving a packet.
What exactly is wrong with these 2 functions? The packet is sent, but never received
Fucntion for receiving

bool SprejmiTest(unsigned short port)
{
       
        sf::Packet PacketTest2;
        sf::IpAddress IpEna;
        unsigned short Port;
        std::string Beseda;



        sf::UdpSocket SocketServerTest;
        SocketServerTest.setBlocking(0);
        SocketServerTest.bind(port);
        if(SocketServerTest.receive(PacketTest2,IpEna,Port)==sf::Socket::Done){
        PacketTest2>>Beseda;
        std::cout<<Beseda<<std::endl;
        std::cout<<"Testni paket je sprejet"<<std::endl;
        return true;}
          else
             return false;


}
       

Function for sending

bool PosljiTest(sf::IpAddress IpTest,unsigned short PortTest)
{

        std::string Beseda="Zivjo";
        sf::Packet PacketTest;
        sf::UdpSocket SocketTest;
        SocketTest.setBlocking(0);
       
        PacketTest<<Beseda;
        if(SocketTest.send(PacketTest,IpTest,PortTest)!=sf::Socket::Done){std::cout<<"Paket ni bil poslan";return false;}
        std::cout<<"Paket poslan"<<std::endl;
        return true;

}

Thank you!

Pages: [1]
anything