New to lidgren

219 views
Skip to first unread message

VileStorms

unread,
Mar 13, 2021, 9:06:57 PM3/13/21
to lidgren-network-gen3

Hey all I'm just learning all the lidgren stuff and I'm trying to send a message to a server when someone clicks a button with the following code

[code]
NetOutgoingMessage sendMsg = netClient.CreateMessage();

            sendMsg.Write("hello server");

            netClient.SendMessage(sendMsg, NetDeliveryMethod.ReliableOrdered);
[/code]

when the server decyphers the message it reads out as this in the console

" Rem 1818588271"

this is the server side code on receiving the message:

[code]
NetIncomingMessage msg;
            while ((msg = server.ReadMessage()) != null) {
                switch (msg.MessageType) {
                    case NetIncomingMessageType.Data:
                        string str = msg.ReadString();
                        int a = msg.ReadInt32();
                        Debug.WriteLine(str + " " + a);
                        break;
                    default:
                        Debug.WriteLine("Unhandled type: " + msg.MessageType);
                        break;
                }
                server.Recycle(msg);
            }
[/code]
Reply all
Reply to author
Forward
0 new messages