C# Class Squishy.Network.ConnectionWriter

The ConnectionWriter provides several methods to send continuous data from a Stream. When either the Connection disconnects, reading fails or no more data can be read, the stream will be closed after the corresponding event has been raised if CloseStreamAfterTranscaction is set to true - otherwise left open.
Datei anzeigen Open project: jaddie/WCell-Utility-Bot

Public Properties

Property Type Description
CloseStreamAfterTransaction bool

Public Methods

Method Description
ConnectionWriter ( ) : System
ConnectionWriter ( Connection con ) : System
Stop ( ) : void

Stops reading and -if CloseStreamAfterTransaction is true- also closes the underlying stream.

WriteAll ( Stream stream ) : void

If not writing yet, asynchronously sends everything that can be read from this stream.

WriteFile ( FileInfo file ) : void

If not writing yet, opens a readonly-stream to the given file and will asynchronously send it to the remote connection.

Private Methods

Method Description
ContinueReadStreamData ( ) : void
DataReadFailedNotify ( Exception e ) : void
DataSentNotify ( ) : void
InitWrite ( Stream stream ) : void
OnInternalDisconnected ( Connection con, bool conLost ) : void
OnInternalSent ( Connection con, int amount, bool hasReamining ) : void
OnStreamRead ( IAsyncResult ar ) : void
ResetAfterTransfer ( ) : void

Method Details

ConnectionWriter() public method

public ConnectionWriter ( ) : System
return System

ConnectionWriter() public method

public ConnectionWriter ( Connection con ) : System
con Connection
return System

Stop() public method

Stops reading and -if CloseStreamAfterTransaction is true- also closes the underlying stream.
public Stop ( ) : void
return void

WriteAll() public method

If not writing yet, asynchronously sends everything that can be read from this stream.
public WriteAll ( Stream stream ) : void
stream Stream
return void

WriteFile() public method

If not writing yet, opens a readonly-stream to the given file and will asynchronously send it to the remote connection.
public WriteFile ( FileInfo file ) : void
file FileInfo
return void

Property Details

CloseStreamAfterTransaction public_oe property

Indicates wether to close the Stream when failed or finished reading. Default: true
public bool CloseStreamAfterTransaction
return bool