Well I want to send commands and data between client and server.
I have three projects:
- Client
- Server
- Common - here I put common classes and network abstraction layer
I am using following data structures for communications between client and server
public class Packet<T>
{
public string Name { get; set; }
public string From { get; set; }
public string To { get; set; }
public PacketType PacketType { get; set; }
public T Container { get; set; }
public Packet()
{
}
public Packet(string name, PacketType packetType, T container)
{
Name = name;
PacketType = packetType;
Container = container;
}
}
public enum PacketType
{
Command,
Data
}
If I need to send information about files I just create a packet with the necessary structure CreatePacket<FilesInfo>(filesInfo)
and then serialize it and send it to client\server.
But how I can deserialize data on receiving side? I don't know what is object type the packet is. Is there any other way or library or something to solve my problem? Also I don't want to use WCF because my app should work on machines with .NET 2.0 installed.