+ 7
How to encode message type in lidgren.network.dll
I know how to communicate between clients and server and how to send messages. But that's not enough. I need to somehow include another string in SendMessage() method that specifies what kind of data it is. Is it a basic message or is It a new connection or is it like some kind of request. Depends on the type the event in the other end will act differently. Help me out guys.
3 odpowiedzi
+ 2
Recommendation (not an answer unfortunately), you could try asking the question here:
https://groups.google.com/forum/#!forum/lidgren-network-gen3
Which appears to be the official Lidgren help page.
+ 1
You may do something like this:
// Client portion
client.SendMessage(
message + ":float");
//Server portion
... {
var fullMsg = server.ReceiveMessage();
var realMsg = fullMsg.Split(':')[0];
var msgType = fullMsg.Split(':')[1];
switch (msgType)
{
case "string" :
StringType?.Invoke(realMsg);
break;
case "float" :
FloatType?.Invoke(realMsg);
break;
default :
throw new Exception (
"Wrong data type);
}
} ...
This is just a guessing of what you're trying to do, hope it helps.
0
I just re-read what you wrote and changed the answer accordingly, putting the events instead of the previous return statements