StreamWorker Class

From RemObjects Wiki
Jump to: navigation, search

This is a Library topic for RemObjects SDK for .NET
This page is generated from external data, please do not update

NamespacesInterfacesClassesEnumsImplements

Contents

Overview

This class is used internally by ROZeroConfClient class to handle network communication with ROZeroConf_Hub encapsulating reading/writing socket stream and packing/unpacking data in a format required by ZeroConf protocol.

The class uses an internal binary format that is determined by ROZeroConf_Hub. A common request/response contains an operation name and a set of key-value pairs - operation parameters.

There is no need to use this class directly.

For internal use only.


Location


Properties

MaxLength

A maximum size of data in one package. Default value is equal to 1MB.



Prism:   property MaxLength: Int32 read write
C#:   Int32 MaxLength { get; set; }
VB:   Property MaxLength As Int32


RemoteMaxLength

The value of property is set during communication with ROZeroConf_Hub and shows the maximum package size that is set on the Hub.



Prism:   property RemoteMaxLength: Int32 read write
C#:   Int32 RemoteMaxLength { get; set; }
VB:   Property RemoteMaxLength As Int32


Stream

Returns the socket stream that is used by the class instance to perform network communication.



Prism:   property Stream: Stream read
C#:   Stream Stream { get; }
VB:   Property ReadOnly Stream As Stream


UserData

not used.



Prism:   property UserData: Object read write
C#:   Object UserData { get; set; }
VB:   Property UserData As Object


Class Methods

DecodePackage

Unpacks binary data returned from ROZeroConf_Hub into the operation name and the array of key-pair values (operation parameters).


Oxygene:   class method DecodePackage(data: array of Byte; bytesToSkip: Int32; out name: String; out parameters: array of KeyValuePair<String,array of Byte>)
C#:   static void DecodePackage(array of Byte data, Int32 bytesToSkip, out String name, out array of KeyValuePair<String,array of Byte> parameters)
VB:   Shared Sub DecodePackage(data As array of Byte, bytesToSkip As Int32, <OutAttribute> ByRef name As String, <OutAttribute> ByRef parameters As array of KeyValuePair<String,array of Byte>)


Parameters:

  • data: a binary data to unpack.
  • bytesToSkip: a number of bytes to skip from the start of the data.
  • name: a name of the operation returned from ROZeroConf_Hub.
  • parameters: parameters of the operation.


EncodePackage

Packs command from client (operation name and key-value pairs of parameters) to binary format.


Oxygene:   class method EncodePackage(command: String; length: Boolean; prefix: array of Byte; parameters: array of KeyValuePair<String,array of Byte>): array of Byte
C#:   static array of Byte EncodePackage(String command, Boolean length, array of Byte prefix, array of KeyValuePair<String,array of Byte> parameters)
VB:   Shared Function EncodePackage(command As String, length As Boolean, prefix As array of Byte, parameters As array of KeyValuePair<String,array of Byte>) As array of Byte


Parameters:

  • command: an operation name.
  • length: defines whether to store the stream length at its beginning.
  • prefix: a prefix to write at the beginning of the binary package.
  • parameters: operation parameters itself.


Int32FromBuffer

Read 4 bytes from binary buffer and converts them to Int32 value.


Oxygene:   class method Int32FromBuffer(buffer: array of Byte): Int32
C#:   static Int32 Int32FromBuffer(array of Byte buffer)
VB:   Shared Function Int32FromBuffer(buffer As array of Byte) As Int32


Parameters:

  • buffer: a binary buffer to read from.


Instance Methods

constructor

Creates an instance of an object, assigning callbacks and a socket stream to it.


Oxygene:   constructor(callbacks: IStreamWorkerCallbacks; stream: Stream)
C#:   constructor(IStreamWorkerCallbacks callbacks, Stream stream)
VB:   Sub New (callbacks As IStreamWorkerCallbacks, stream As Stream)


Parameters:

  • callbacks: callbacks to be fired on the end of network operations.
  • stream: a socket stream instance to work with.


GenerateID

Used to generate a new Id (integer value) to synchronize waiting requests with callbacks.


Oxygene:   method GenerateID(positive: Boolean): Int32
C#:   Int32 GenerateID(Boolean positive)
VB:   Function GenerateID(positive As Boolean) As Int32


Parameters:

  • positive: set whether the method should return a positive or negative ID.


SendControlPackage

Sends a package with command and parameters to Hub. The first 4 bytes of the package are the length of entire package.


Oxygene:   method SendControlPackage(command: String; parameters: array of KeyValuePair<String,array of Byte>)
C#:   void SendControlPackage(String command, array of KeyValuePair<String,array of Byte> parameters)
VB:   Sub SendControlPackage(command As String, parameters As array of KeyValuePair<String,array of Byte>)


Parameters:

  • command: a name of the command to send.
  • parameters: command parameters.


SendData

Sends previously packed data over the network stream. If stream is busy at the moment, it stores the binary package to the send queue.


Oxygene:   method SendData(data: array of Byte)
C#:   void SendData(array of Byte data)
VB:   Sub SendData(data As array of Byte)


Parameters:

  • data: a binary package to send.


Start

Starts network communication with Hub by sending "hello" package ROSW and and subscribes for a response. Method is called one time right after class instance creation. Further calls will be ignored.


Oxygene:   method Start
C#:   void Start()
VB:   Sub Start


See Also


Product: RemObjects SDK
Available Editions: RemObjects SDK for .NET, Xcode, Delphi, Java and JavaScript

GlossaryArticlesLibrarySamples

Personal tools
Namespaces

Variants
Actions
Navigation
products
platforms
special
Toolbox