Skip to content

501f2cde 1d49 c096 44c2 528e3a568622

Arthur Frederico Neves edited this page Jul 19, 2016 · 6 revisions

TCPPublisher ClassPublisher that uses the TCP protocol for sending and receiving packs

Inheritance Hierarchy

System.Object
  NETLIB.Publisher
    NETLIB.TCP.TCPPublisher
Namespace: NETLIB.TCP
Assembly: NETLIB (in NETLIB.dll) Version: 1.0.0.0 (1.0.0.0)

Syntax

C#

public class TCPPublisher : Publisher

VB

Public Class TCPPublisher
	Inherits Publisher

C++

public ref class TCPPublisher : public Publisher

F#

type TCPPublisher =  
    class
        inherit Publisher
    end

The TCPPublisher type exposes the following members.

Constructors

 

Name Description
Public method TCPPublisher(Stream) Initializes the publisher with a existing client TCP stream.
Public method TCPPublisher(String, Int32) Initializes the publisher and creates a TCP connection using the IP and port.
  Back to Top

Properties

 

Name Description
Public property IncomingPackEvent Event signaling that a packet arrived. (Inherited from Publisher.)
Public property InputOutput TCP client stream.
Public property IsAlive Boolean indicating whether the stream is still alive and able to receive new packages. (Inherited from Publisher.)
Public property IsEnabled Boolean indicating whether the publisher is currently active, publishing packages. (Inherited from Publisher.)
Public property PackQueue Gets the pack queue (Inherited from Publisher.)
  Back to Top

Methods

 

Name Description
Public method CloseConnection Stop listening packets, closes the stream and reset the properties of the publisher (Overrides Publisher.CloseConnection().)
Public method Dispose Closes the connection, and resets the states of the publisher. (Inherited from Publisher.)
Public method Equals Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected method Finalize Release resources in the death of the object if the Dispose() method was not used properly. (Inherited from Publisher.)
Public method GetHashCode Serves as the default hash function. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Protected method OnConnectionClosedCall Calls ConnectionClosedEvent (Inherited from Publisher.)
Protected method Publish Method responsible for receiving packets of stream and puts them in the packet queue and signal the incoming pack event. (Overrides Publisher.Publish().)
Public method SendPack(Byte[], IPEndPoint) Sends the packet through the TCP stream. (Overrides Publisher.SendPack(Byte[], IPEndPoint).)
Public method SendPack(BasePack, IPEndPoint) Sends the packet through the TCP stream. (Overrides Publisher.SendPack(BasePack, IPEndPoint).)
Public method Start Starts the packages listening/receive thread. (Inherited from Publisher.)
Public method Stop Stops the packages listening/receive thread. (Inherited from Publisher.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
  Back to Top

Events

 

Name Description
Public event ConnectionClosed Event used to signal when the connection (input stream) was closed for any reason. (Inherited from Publisher.)
  Back to Top

Fields

 

Name Description
Protected field incomingPackEvent Event signaling that a packet arrived. (Inherited from Publisher.)
Protected field isAlive Boolean indicating whether the stream is still alive and able to receive new packages. (Inherited from Publisher.)
Protected field isEnabled Boolean indicating whether the publisher is currently active, publishing packages. (Inherited from Publisher.)
Protected field packQueue Queue that stores incoming packets. (Inherited from Publisher.)
Protected field publisherThread Thread that will run the reception and publication of packs. (Inherited from Publisher.)
  Back to Top

Examples

The following example code shows two ways of instantiating a new TCPPublisher

public void NewTCPPublisherExampleMethod()
{
    var publisher = new TCPPublisher("127.0.0.1", 1975);
}

public void NewTCPPublisherExampleMethod()
{
    TcpClient client = new TcpClient(ip, port);
    var publisher = new TCPPublisher(client.GetStream());
}

See Also

Reference

NETLIB.TCP Namespace
NETLIB.Publisher
NETLIB.BasePack
NETLIB.Consumer(TPack)

Clone this wiki locally