I have grabbed the latest edition of Lidgren, from https://code.google.com/p/lidgren-network-gen3/
I've reviewed many tutorials, but none seem to work. I presume I must be missing something in my code.
using Lidgren.Network;
using System;
namespace LGServer
{
class Program
{
static void Main(string[] args)
{
NetPeerConfiguration config = new NetPeerConfiguration("test");
config.Port = 5432;
config.LocalAddress = new System.Net.IPAddress(new byte[] { 127, 0, 0, 1 });
config.MaximumConnections = 1000;
NetServer server = new NetServer(config);
server.Start();
NetIncomingMessage msg = null;
while (true)
{
while ((msg = server.ReadMessage()) != null)
{
Console.WriteLine(msg.MessageType.ToString());
if (msg.MessageType == NetIncomingMessageType.Data)
{
Console.WriteLine(msg.ReadInt16());
Console.WriteLine(msg.ReadString());
}
}
}
}
}
}
//// My client code:
using Lidgren.Network;
using System;
namespace LGClient
{
class Program
{
static void Main(string[] args)
{
NetPeerConfiguration config = new NetPeerConfiguration("test");
NetClient client = new NetClient(config);
client.Start();
client.Connect("127.0.0.1", 5432);
NetOutgoingMessage msg = client.CreateMessage();
msg.Write((Int16)3346);
msg.Write("Test Message 1 whooahaa");
client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
client.FlushSendQueue();
}
}
}
The server gets a status change every time I connect (?status changes from running to running?) Then I get a debug message with the time it takes between client/server
But I never get the data message. does this code work on someone elses machine? is there something obvious I'm missing?
Thanks.