Class ComponentPort

Definition

Namespace:
Tizen.Applications.ComponentBased
Assembly:
Tizen.Applications.ComponentBased.Port.dll

The component port API provides functions to send and receive requests between components of component-based-application.

C#
Copy
public class ComponentPort : IDisposable
Inheritance
object
ComponentPort
Implements
System.IDisposable

Constructors

View Source

ComponentPort(string)

Constructs a new instance of this class.

Declaration
C#
Copy
public ComponentPort(string portName)
Parameters
Type Name Description
string portName

The name of the port to connect to.

Exceptions
Type Condition
System.ArgumentException

Thrown when the argument is invalid.

System.OutOfMemoryException

Thrown when the memory is insufficient.

System.IO.IOException

Thrown when because of I/O error.

Properties

View Source

PortName

Gets the port name.

Declaration
C#
Copy
public string PortName { get; }
Property Value
Type Description
string

Methods

View Source

AddPrivilege(string)

Adds a privilege to the port object.

Declaration
C#
Copy
public void AddPrivilege(string privilege)
Parameters
Type Name Description
string privilege

Privilege data specifying the access rights to be granted.

Exceptions
Type Condition
System.ArgumentException

Thrown when the argument is invalid.

View Source

Cancel()

Cancels waiting for events.

Declaration
C#
Copy
public void Cancel()
View Source

Dispose()

Releases all the resources used by the class ComponentPort.

Declaration
C#
Copy
public void Dispose()
View Source

Dispose(bool)

Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.

Declaration
C#
Copy
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing

If true, disposes any disposable objects, or false not to dispose disposable objects.

View Source

~ComponentPort()

Finalizes an instance of the class ComponentPort.

Declaration
C#
Copy
protected ~ComponentPort()
View Source

Send(string, int, object)

Sends the request data to the specified endpoint.

Declaration
C#
Copy
public void Send(string endpoint, int timeout, object request)
Parameters
Type Name Description
string endpoint

The name of the endpoint to which the request is sent.

int timeout

The timeout in milliseconds, -1 to use the default timeout.

object request

The serializable data to send.

Remarks

This method sends the serialized request data to the specified endpoint. If the timeout value is not set (-1), the default timeout will be used.

Exceptions
Type Condition
System.ArgumentException

Thrown when the argument is invalid.

System.OutOfMemoryException

Thrown when the memory is insufficient.

System.UnauthorizedAccessException

Thrown when permission is denied.

System.IO.IOException

Thrown when because of I/O error.

View Source

SendAndReceive(string, int, object)

Sends the request data and receives the reply data.

Declaration
C#
Copy
public object SendAndReceive(string endpoint, int timeout, object request)
Parameters
Type Name Description
string endpoint

The name of the endpoint to which the request is sent.

int timeout

The timeout in milliseconds, -1 to use the default timeout.

object request

The serializable data to send.

Returns
Type Description
object

The received serializable data.

Exceptions
Type Condition
System.ArgumentException

Thrown when the argument is invalid.

System.OutOfMemoryException

Thrown when the memory is insufficient.

System.UnauthorizedAccessException

Thrown when permission is denied.

System.IO.IOException

Thrown when because of I/O error.

View Source

SendAndReceiveAsync(string, int, object)

Sends the request data and receives the reply data asynchronously.

Declaration
C#
Copy
public Task<object> SendAndReceiveAsync(string endpoint, int timeout, object request)
Parameters
Type Name Description
string endpoint

The name of the endpoint to which the request is sent.

int timeout

The timeout in milliseconds, -1 to use the default timeout.

object request

The serializable data to send.

Returns
Type Description
System.Threading.Tasks.Task<TResult><object>

The received serializable data.

Exceptions
Type Condition
System.ArgumentException

Thrown when the argument is invalid.

System.OutOfMemoryException

Thrown when the memory is insufficient.

System.UnauthorizedAccessException

Thrown when permission is denied.

System.IO.IOException

Thrown when because of I/O error.

View Source

WaitForEvent()

Waits for events.

Declaration
C#
Copy
public void WaitForEvent()
Remarks

This method runs a main loop until Cancel() is called. The code in the next line will not execute until Cancel() is called. To prevent blocking the main thread, consider using the ComponentTask class instead.

Examples
Copy
ComponentTask task = new ComponentTask(new ComponentPort("Comm")); task.Start();
View Source

WaitForPort(string)

Waits until the port is ready.

Declaration
C#
Copy
public static Task WaitForPort(string endpoint)
Parameters
Type Name Description
string endpoint

The name of the port

Returns
Type Description
System.Threading.Tasks.Task

A task.

Events

View Source

RequestReceived

Occurs whenever the request is received.

Declaration
C#
Copy
public event EventHandler<RequestEventArgs> RequestReceived
Event Type
Type Description
System.EventHandler<TEventArgs><RequestEventArgs>
Remarks

The event handler receives a RequestEventArgs argument that contains information about the request. If the reply is requested, RequestEventArgs.Request should be set.

Implements

System.IDisposable