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

Pages: [1]
1
Window / Re: SetFramerateLimit makes the Game stutter
« on: July 30, 2013, 12:55:33 pm »
Also when i enable VSync its fine, but loads CPU on 100%

2
Window / Re: SetFramerateLimit makes the Game stutter
« on: July 30, 2013, 12:04:38 pm »
Have same problem, the most bad thing is sf::View scrolling. It stutters as hell!

3
Network / Re: Cant receive/send data after using socket
« on: June 10, 2013, 08:53:58 pm »
Okay, there is another problem.
I used example from doc and when client disconnects from server, server load CP a lot. Before disconnect server load less than 1%, but after it loads about 40%.
What can i do with it?
Thanks.

4
Network / Re: Cant receive/send data after using socket
« on: June 10, 2013, 05:17:36 pm »
Thanks, this example helped a lot.

5
Network / Re: Cant receive/send data after using socket
« on: June 09, 2013, 10:56:22 pm »
Got it work.
Now i use thread in server.
Current problem is multiple clients.
void doWork(void)
{
        listener.listen(PORT);
        listener.accept(socket);
        selector.add(socket);
        socketsList.push_front(socket);

        while(!quit)
        {
                //Check requests
                sf::Packet packetReceive;
                string msg;

                if (socket.receive(packetReceive) != sf::Socket::Done)
                {
                        cout << "Client leaved: " + socket.getRemoteAddress().toString() << endl;
                }

                if (packetReceive >> msg)
                {
                        if (msg == "mapNameRequest")
                        {
                                sf::Packet packetSend;
                                globalMutex.lock();
                                packetSend << gameMap;
                                globalMutex.unlock();
                                if (socket.send(packetSend) != sf::Socket::Done)
                                {
                                        cout << "ERROR4" << endl;
                                }
                        }

                        if (msg == "gameSessionNameRequest")
                        {
                                sf::Packet packetSend;
                                globalMutex.lock();
                                packetSend << gameSession.getGameSessionName();
                                globalMutex.unlock();
                                if (socket.send(packetSend) != sf::Socket::Done)
                                {
                                        cout << "ERROR4" << endl;
                                }
                        }
                }
        }
}
 

How to do it?
Am i need to use new thread for each client?

6
Network / [UPD3] Disconnect loads CP a lot
« on: June 09, 2013, 06:28:24 pm »
Hi.
I am completly newbie in network programming, so got some problems in my project.
Here is some code.
Client:
if (socket.connect("127.0.0.1", 12312) != sf::Socket::Done)
{
        cout << "ERROR1" << endl;
}

sf::Packet packetSend;
packetSend << "mapNameRequest";
if (socket.send(packetSend) != sf::Socket::Done)
{
        cout << "ERROR2" << endl;
}

while (mapName == "")
{
        sf::Packet packetReceive;
        socket.receive(packetReceive);
        packetReceive >> mapName;
}

//breakpoint
packetSend << "gameSessionNameRequest";
if (socket.send(packetSend) != sf::Socket::Done)
{
        cout << "ERROR2" << endl;
}

while (gameSession.getGameSessionName() == "")
{
        string msg;
        sf::Packet packetReceive;
        socket.receive(packetReceive);
        packetReceive >> msg;
        gameSession.setGameSessionName(msg);
}
 

Server:
listener.listen(PORT);

//Check requests
sf::Packet packetReceive;
string msg;
while(!quit)
{
        if (listener.accept(socket) != sf::Socket::Done)
        {
                cout << "ERROR2" << endl;
        }

        if (socket.receive(packetReceive) != sf::Socket::Done)
        {
                cout << "ERROR3" << endl;
        }

        if (packetReceive >> msg)
        {
                if (msg == "mapNameRequest")
                {
                        sf::Packet packetSend;
                        packetSend << gameMap;
                        if (socket.send(packetSend) != sf::Socket::Done)
                        {
                                cout << "ERROR4" << endl;
                        }
                }

                if (msg == "gameSessionNameRequest")
                {
                        sf::Packet packetSend;
                        packetSend << gameSession.getGameSessionName();
                        if (socket.send(packetSend) != sf::Socket::Done)
                        {
                                cout << "ERROR4" << endl;
                        }
                }
        }
}
 

The problem is in client code. The first request is okay,client can receive mapName.
But after "//breakpoint" there are some porblems.
Client freezes at second "while" cycle. It cant receive "gameSessionNameRequest".
Sorry if question is too stupid.

Thanks.

Pages: [1]