Design support for a network application?

NOTIFICATION

This is a pretty big question, so please bear with me, and I apologize in advance if this is unclear. To make this question manageable and to minimize confusion, I omit some properties from the copy and paste classes.

CONTEXT

I am writing a network application - an application such as "remote desktop", so that the average technician-developer can help his friends or neighbors with computer problems. I understand free and much more advanced software such as TeamViewer, but this question does not discuss the practicality of creating this software.

GENERAL TERMS AND CONDITIONS

The client is a technical developer, the assistant is the controller. A server is a "victim" who is in distress. Typically, a client typically runs commands on the server.

INFORMATION

This software is more than a live view / control app. I need additional modules, such as a file explorer module and a chat module (so that they can communicate without using additional instant messaging software).

Initially, my approach to sending and receiving messages via UDP was manual and inefficient. (I use the Lidgren library for UDP networks, so why my packets do not show low bytes, such as the size of the header message.)

Original Packet Structure:

Byte Index    Type      Purpose/Description
------------------------------------------------------
0             byte      The intended destination module (e.g. 1 -> Chat module)
1             byte      The command for this module to perform (e.g. 0 -> NewChatMessage)
2             byte      Encryption/compression flag
3             byte      Packet priority flag (e.g. Cancel packets should be processed first)
4-X            ?        Command-specific arguments of variable type (e.g. For this example, the argument would be the actual chat message text)

, 100 . , . " " "" (- ) . , if-else.

. , ( ), - . , .

Revised Packet Structure:

Byte Index    Type      Purpose/Description
------------------------------------------------------
0-X           String    Serialized class

. - . , /. , . :

/// <summary>
/// The fundamental unit of network communication which can be transmitted and received from client to server. Contains the destination module and module-specific command.
/// </summary>
public class Packet
{
    /// <summary>
    /// Specifies the module this packet is forwarded to.
    /// </summary>
    public Module DestinationModule { get; set; }

    /// <summary>
    /// Specifies whether this packet is encrypted or compressed.
    /// </summary>
    public EncryptionCompressionFlag EncryptedOrCompressed { get; set; }

    /// <summary>
    /// Specifies the packet priority.
    /// </summary>
    public PacketPriority Priority { get; set; }
}

( )

/// <summary>
/// Base packet structure for packets specific to this module. Adds a ModuleCommand property from the base Packet class.
/// </summary>
public class WelcomeModulePacket : Packet
{
    /// <summary>
    /// Specifies the command number this particular packet is instructing the module to execute.
    /// </summary>
    public ModuleCommand Command { get; set; }
}

/// <summary>
/// Specifies the commands for this module.
/// </summary>
public enum ModuleCommand : byte
{
    /// <summary>
    /// The user has just clicked the Connect button (on form GUI) and is sending this connect packet.
    /// </summary>
    ClientRequestingConnectionPacket = 0,

}

WelcomeModulePacket:

, , "CommandModule", , . "ModuleCommand" .

/// <summary>
/// The user has just clicked "Connect" on the Welcome form of the client. The client is now requesting a connection to the server.
/// </summary>
public class ClientRequestingConnectionPacket : WelcomeModulePacket
{
    public string Username { get; set; }
    public string Password { get; set; }
}

, , , .

ClientRequestingConnectionPacket : WelcomeModulePacket : Packet

, , ClientRequestingConnectionPacket, . , enqueuing "ClientRequestingConnectionPacket" PriorityQueue ( , "Packet" "PacketPriority" ). , , ClientRequestingConnectionPacket. , , , , , - ClientRequestingConnectionPacket, , .

, , :

Type UltimateType { get; set; }

"". , "" , .

, StackOverflow, ? ? ? ?

: ?

+5
2

GetType, FishBasketGordo, is

if (packet is ClientRequestingConnectionPacket)
{ /* do something */ }
else if (packet is SomeOtherPacket)
....
+1

, , GetType? , , , , . , .

+1

All Articles