lnobad / lidgren-network-gen3

Automatically exported from code.google.com/p/lidgren-network-gen3
0 stars 0 forks source link

Object reference not set to an instance of an object. #166

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
On the client side, i connect to the server. Then from the server side i 
approve the connection and send a remotehailmessage. Then, from the client 
side, the line right after the connect line is:

identification = client.ServerConnection.RemoteHailMessage.ReadInt32();

(This is so that the clients can be differentiated.)

But the client gives me the error: Object reference not set to an instance of 
an object. because the hailmessage is null!

Please help me, and tell me if you need all of the code for both.

Original issue reported on code.google.com by vesnaboz...@gmail.com on 1 Jul 2014 at 7:30

GoogleCodeExporter commented 9 years ago
Anyone?

Original comment by vesnaboz...@gmail.com on 4 Jul 2014 at 10:13

GoogleCodeExporter commented 9 years ago
You should check out the Chat sample; it uses a hail message. It only does 
client->server hail, but I just verified server->client hail, and it works fine.

Original comment by lidg...@gmail.com on 4 Jul 2014 at 11:35

GoogleCodeExporter commented 9 years ago
Could you give me a link to it, please?

Original comment by vesnaboz...@gmail.com on 4 Jul 2014 at 1:25

GoogleCodeExporter commented 9 years ago
It's in the Samples folder of the source code; you'll need SVN to access it: 
https://code.google.com/p/lidgren-network-gen3/source/checkout

Original comment by lidg...@gmail.com on 4 Jul 2014 at 1:51

GoogleCodeExporter commented 9 years ago
Uh; this is more exact link: 
https://code.google.com/p/lidgren-network-gen3/source/browse/

Original comment by lidg...@gmail.com on 4 Jul 2014 at 1:52

GoogleCodeExporter commented 9 years ago
Thanks, I'll check that out.

Original comment by vesnaboz...@gmail.com on 4 Jul 2014 at 2:56

GoogleCodeExporter commented 9 years ago
Well, I tried to follow it by changing my code to this:

                else if (recv.MessageType == NetIncomingMessageType.StatusChanged)
                {
                    NetConnectionStatus status = (NetConnectionStatus)recv.ReadByte();
                    if (status == NetConnectionStatus.Connected)
                    {
                        identification = recv.SenderConnection.RemoteHailMessage.ReadInt32();
                    }
                }

but it still says the same error about the hail message being null.
From the server side I just have it be:

                    if (recv.MessageType == NetIncomingMessageType.ConnectionApproval)
                    {
                        send = server.CreateMessage();
                        send.Write(pos.Count);
                        recv.SenderConnection.Approve(send);
                    }

It's probably something simple I didn't even know about..

Original comment by vesnaboz...@gmail.com on 4 Jul 2014 at 3:59

GoogleCodeExporter commented 9 years ago
The code you posted looks ok; not sure what goes wrong.

Original comment by lidg...@gmail.com on 4 Jul 2014 at 5:35

GoogleCodeExporter commented 9 years ago
Thanks for trying to help anyway :). Maybe someone else knows. Maybe it's not 
the code.

Original comment by vesnaboz...@gmail.com on 4 Jul 2014 at 6:53

GoogleCodeExporter commented 9 years ago
Does anyone else see the problem?

Original comment by vesnaboz...@gmail.com on 5 Jul 2014 at 9:27