I am using lidgren as a networking library for a small xnaXNA game. I am using a server client/server architecture for the game. Currently, I have the client and server connecting but I would like to be able to pass an enum with a character type when the client requests to join the server. Here is a sample of my code:
while ((inMsg = networkManager.ReadMessage()) != null)
{
switch (inMsg.MessageType){
case NetIncomingMessageType.StatusChanged:
switch ((NetConnectionStatus)inMsg.ReadByte()){
case NetConnectionStatus.Connected:
if (!this.isHosting)
{
//Extract player info from message and create a local player
}break;
case NetConnectionStatus.RespondedAwaitingApproval:
pType = (PlayerType)inMsg.ReadByte();
playerManager.AddPlayer(pType);
//Then I will send the player information to the client
inMsg.SenderConnection.Approve();
break;
}
break;
}
this.networkManager.Recycle(inMsg);
}
So whenWhen server gets a message with RespondedAwaitingApprovalRespondedAwaitingApproval flag, iI would like to be able to read the message,extract extract the type and create an instance of a player of that type. How can I accomplish that?