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#Copypublic class ComponentPort : IDisposable
- Inheritance
-
objectComponentPort
- Implements
-
System.IDisposable
Constructors
Declaration
C#Copypublic 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
Declaration
C#Copypublic string PortName { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
Declaration
C#Copypublic 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. |
Declaration
C#Copypublic void Cancel()
Declaration
C#Copypublic void Dispose()
Dispose(bool)
Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
Declaration
C#Copyprotected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing | If true, disposes any disposable objects, or false not to dispose disposable objects. |
Declaration
C#Copyprotected ~ComponentPort()
Declaration
C#Copypublic 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. |
Declaration
C#Copypublic 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. |
SendAndReceiveAsync(string, int, object)
Sends the request data and receives the reply data asynchronously.
Declaration
C#Copypublic 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. |
Declaration
C#Copypublic 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
CopyComponentTask task = new ComponentTask(new ComponentPort("Comm")); task.Start();
Declaration
C#Copypublic 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
Declaration
C#Copypublic 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.