lnobad / lidgren-network-gen3

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

Can't read Hail Message #92

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1: 
on Client:
          client.Start();
            NetOutgoingMessage hail = client.CreateMessage();
            hail.Write("Message");
            client.Connect(host, port, hail);

2:  
on Server:
   case NetIncomingMessageType.StatusChanged:
       msg.ReadByte(); // not used for now
       Console.WriteLine(msg.ReadString()); //this gives some debug info like "Initiated average roundtrip time to 6,96 ms Remote time is: 1,89029809832573"
       break;

What is the expected output? What do you see instead?
I don't understand, how to receive this Hail message from client.

What version of the product are you using? On what operating system?
Gen3, XP

Please provide any additional information below.

Original issue reported on code.google.com by tets...@inbox.lv on 5 Oct 2011 at 8:39

GoogleCodeExporter commented 9 years ago
The message is available as msg.SenderConnection.RemoteHailMessage. You need to 
check if it's not null. So youl could something like this:

if(msg.SenderConnection.RemoteHailMessage != null)
{
  Console.WriteLine( msg.SenderConnection.RemoteHailMessage.ReadString() );
}

Original comment by elise...@gmail.com on 9 Oct 2011 at 11:36

GoogleCodeExporter commented 9 years ago
See above comment

Original comment by lidg...@gmail.com on 2 Nov 2011 at 9:29

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I'm sorry for replying on this old topic. But when I receive the hail message 
on the server side, I'm getting this error: Index was outside the bounds of the 
array on the class NetBitWriter.

Original comment by fr92...@gmail.com on 16 Jan 2014 at 1:05

GoogleCodeExporter commented 9 years ago
Check out the Chat sample; it uses the hail message mechanism. Basically you 
need to do:

case NetIncomingMessageType.StatusChanged:
    NetConnectionStatus status = (NetConnectionStatus)im.ReadByte();
    string reason = im.ReadString();

    if (status == NetConnectionStatus.Connected)
        Console.WriteLine("Remote hail: " + im.SenderConnection.RemoteHailMessage.ReadString());
    break;

Original comment by lidg...@gmail.com on 16 Jan 2014 at 8:10