-
Notifications
You must be signed in to change notification settings - Fork 0
cccda63c a26d 7de9 42e0 634381b5a99d
Responsible for managing a communication protocol, in other words, analyze an incoming packet, check for a method of treatment registered for that type of package, if any, the method is called to handle the package, if not a generic event is called to handle the incoming pack. Idealised to facilitate handling packages and management protocols, especially in cases where the client continuously migrates between different protocols.
System.Object
NETLIB.Protocol(TPack)
Namespace: NETLIB
Assembly: NETLIB (in NETLIB.dll) Version: 1.0.0.0 (1.0.0.0)
C#
public class Protocol<TPack>
where TPack : BasePack
VB
Public Class Protocol(Of TPack As BasePack)
C++
generic<typename TPack>
where TPack : BasePack
public ref class Protocol
F#
type Protocol<'TPack when 'TPack : BasePack> = class end
- TPack
- Pack class derived from BasePack that the Protocol will manage.
Name | Description | |
---|---|---|
![]() |
Protocol(TPack)(String) | initializes the Protocol with a empty dictionary of codes. |
![]() |
Protocol(TPack)(String, ThrowPackEventHandler(TPack)[]) | initializes the Protocol with a existing dictionary of methods. |
Name | Description | |
---|---|---|
![]() |
Item | Gets the method reletad to a specific ID. |
![]() |
Name | Name used to identify this protocol. |
![]() |
Triggers | Dictionary of methods used to bind a method of treating to particular ID. Must have 256 or fewer positions because the package ID is represented by a byte. |
Name | Description | |
---|---|---|
![]() |
AddTrigger | Add a method that will be called when the pack's ID is equal 'Key'. |
![]() |
ClearTriggers | Clear all the triggers. |
![]() |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() |
GetHashCode | Serves as the default hash function. (Inherited from Object.) |
![]() |
GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() |
OnReceivedPackCall | Function used to call the method referring to a specific ID |
![]() |
RemoveTrigge | Remove all triggers for a particular ID. |
![]() |
SetTriggers | Set a new dictionary of methods. |
![]() |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
![]() |
ReceivedPack | Generic method used to treat packets without associated methods. |
The following example code shows how to instantiate a new Protocol(TPack) and how to configure the handler methods
public void CreateProtocolExampleMethod()
{
var newProtocol = new Protocol<BasePack>("newProtocol");
newProtocol[0] += ZeroIDHandler;
bewProtocol.ReceivedPack += DefaultIDHundler;
}
private static void ZeroIDHandler(Consumer<BasePack> consumer, BasePack receivedPack)
{
//Do something with the packets that have ID = 0.
}
private static void DefaultIDHundler(Consumer<BasePack> consumer, BasePack receivedPack)
{
//Do something with the packets that do not have a handler method registered.
}
A Sandcastle Documented Class Library
Send comments on this topic to [](mailto:?Subject=A Sandcastle Documented Class Library)
-
NETLIB Namespace
-
BasePack Class
- BasePack Constructor
- BasePack Properties
-
BasePack Methods
- BasePack.DeepCopy Method
- BasePack.GetBool Method
- BasePack.GetByte Method
- BasePack.GetChar Method
- BasePack.GetDouble Method
- BasePack.GetFloat Method
- BasePack.GetInt Method
- BasePack.GetPackable(CustomType) Method
- BasePack.GetString Method
- BasePack.PutBool Method
- BasePack.PutByte Method
- BasePack.PutChar Method
- BasePack.PutDouble Method
- BasePack.PutFloat Method
- BasePack.PutInt Method
- BasePack.PutPackable(CustomType) Method
- BasePack.PutString Method
- BasePack.Read Method
- BasePack.Write Method
- BasePack Type Conversions
- BasePack Fields
- ConnectionClosedEventHandler Delegate
- ConnectionClosedEventHandler(Type) Delegate
- ConnectionClosedException Class
-
Consumer(TPack) Class
- Consumer(TPack) Constructor
- Consumer(TPack) Properties
-
Consumer(TPack) Methods
- Consumer(TPack).CloseConnection Method
- Consumer(TPack).Dispose Method
- Consumer(TPack).EndConsume Method
- Consumer(TPack).EndPublishConsume Method
- Consumer(TPack).Finalize Method
- Consumer(TPack).OnReceivedPackCall Method
- Consumer(TPack).PackFactory Method
- Consumer(TPack).SendPack Method
- Consumer(TPack).Start Method
- Consumer(TPack).StartConsume Method
- Consumer(TPack) Events
- ConsumerRunningException Class
- IOBasePackHandler Class
- IOPackHandler(TPack) Class
- IPackable Interface
- ListenerRunnigException Class
- Protocol(TPack) Class
-
Publisher Class
- Publisher Constructor
- Publisher Properties
- Publisher Methods
- Publisher Events
- Publisher Fields
- PublisherRunnigException Class
- ThrowPackEventHandler(TPack) Delegate
-
BasePack Class
- NETLIB.TCP Namespace
- NETLIB.TCP.Server Namespace