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 - Static

Pages: [1]
1
General discussions / Build sfeMovie against new version of ffmpeg?
« on: September 19, 2023, 10:06:26 am »
Hi,

is it possible to build sfeMovie against new version (or newer version) of ffmpeg than 2.8?
If so what it takes to get job done? I have succeed to build the sfeMovie with Visual Studio so far (with ffmpeg 2.8 ), but there is an issue to use sfeMovie on Windows Server 2019 (crash). On Win 10 works fine. Maybe the old version of the ffmpeg is the issue?

 

2
Hi!

I'm new on the forum, and have some experience on SFML. What a great library, thank you devs!

I have a problem. I'm trying to send a char from the client to the server over socket. I'm doing this via a key press. When I press a key from the client one time the server receives the key press (char) two times. What's wrong? Is it something to do with the thread? I have tried to figure this out, but I have no brains enough... ;D

client:
    while (window.isOpen()) {
        sf::Event ev;
        while (window.pollEvent(ev)) {
            // Window closure
            if (ev.type == sf::Event::Closed ||
                (ev.type == sf::Event::KeyPressed &&
                    ev.key.code == sf::Keyboard::Escape)) {
                window.close();
            }

            if (ev.type == sf::Event::KeyPressed) {
                if (ev.key.code == sf::Keyboard::Right) {
                                         
                    char keyPressed = 'A';
                    if (socket.send(&keyPressed, sizeof(keyPressed)) == sf::Socket::Done)
                        std::cout << "sending A to server ";

                                 
                }
            }
        }

engine.cpp (server)
void Engine::startServer()
{

        port = 5000;
        client.setBlocking(true);
        std::cout << "Server started...\n";
        if (listener.listen(port) != sf::Socket::Status::Done)
                return;

        std::cout << "- Server is listening to port " << port << std::endl;

        networkThread = std::thread(&Engine::processIncomingData, this);

}

void Engine::processIncomingData(){

while (running) {
        char receivedKeyCode;
        size_t received;

        // Accept client connection and setup...


        sf::Socket::Status status = listener.accept(client);

        if (status == sf::Socket::Done) {
                std::cout << "Client connected: " << client.getRemoteAddress() << std::endl;

                while (running) { // Loop to process key press data

                       

                        sf::Socket::Status receiveStatus = client.receive(&receivedKeyCode, sizeof(receivedKeyCode), received);

                        if (receiveStatus == sf::Socket::Done) {
                                std::cout << "Received key code from client: " << receivedKeyCode << std::endl;

                                // Lock the mutex before accessing shared resources
                                std::lock_guard<std::mutex> lock(callbackMutex);

                                sf::Keyboard::Key pressedKey = static_cast<sf::Keyboard::Key>(receivedKeyCode);

                                if (receivedKeyCode == &#39;A&#39;) {
                                       
                                     

                                                        pressForward();

                                               
                                        }
                               

                        }

                        else if (receiveStatus == sf::Socket::Disconnected) {
                                std::cout << "Client disconnected: " << client.getRemoteAddress() << std::endl;

                                break;
                        }


                }
        }

}


}

Pages: [1]