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

Pages: [1]
1
Network / Re: Not reading third string in packet
« on: December 05, 2020, 07:53:35 am »
Solved, I accidentally was sending the whole player object instead of just the name

2
Network / Not reading third string in packet
« on: December 05, 2020, 07:45:39 am »
I send a packet like this:

void unencryptedMessage(sf::IpAddress recipient, unsigned short port, characterSprite player) {
    sf::Packet packet;
    string packetType = "message";
    packet << packetType << player << player.message;
    if (clientSocket.send(packet, recipient, port) != sf::Socket::Done) {
        cout << "Did not send data." << endl;
    }
    return;
}
 

I then receive the packet like this:
string packetType;
packet >> packetType;
if (packetType == "message"){
            string message;
            packet >> playerName >> message;
            playerMessages[playerName] = message;
            cout << playerName << ": " << message << endl;
        }
 

Let's say the playerName is "Ninjinka" and the message is "Test."

Here is the packet that the server receives:

As you can see, the message doesn't appear to read anything. It only appears to read in the first 27 bytes, whereas the message starts on the 35th byte. Any ideas as to why it's doing this?

Pages: [1]