Class MessagePort

Definition

Namespace:
Tizen.Applications.Messages
Assembly:
Tizen.Applications.MessagePort.dll
API Level:
3

The message port API provides functions to send and receive messages between applications.

C#
Copy
public class MessagePort : IDisposable
Inheritance
MessagePort
Remarks

The message port API provides functions for passing messages between applications. An application should register its own local port to receive messages from remote applications. If a remote application sends a message, the registered callback function of the local port is called. The trusted message-port API allows communications between applications that are signed by the same developer(author) certificate.

Constructors

View Source

MessagePort(String, Boolean)

Initializes the instance of the MessagePort class.

Declaration
C#
Copy
public MessagePort(string portName, bool trusted)
Parameters
Type Name Description
String portName

The name of the local message port.

Boolean trusted

If true, it is the trusted message port of application, otherwise false.

Examples
Copy
MessagePort messagePort = new MessagePort("SenderPort", true);
API Level: 3

Properties

View Source

Listening

If true, the message port is listening, otherwise false.

Declaration
C#
Copy
public bool Listening { get; }
Property Value
Type Description
Boolean
API Level: 3
View Source

PortName

The name of the local message port.

Declaration
C#
Copy
public string PortName { get; }
Property Value
Type Description
String
API Level: 3
View Source

Trusted

If true, the message port is a trusted port, otherwise false.

Declaration
C#
Copy
public bool Trusted { get; }
Property Value
Type Description
Boolean
API Level: 3

Methods

View Source

Dispose()

Releases all resources used by the MessagePort class.

Declaration
C#
Copy
public void Dispose()
API Level: 3
View Source

Dispose(Boolean)

Releases the unmanaged resources used by the MessagePort class specifying whether to perform a normal dispose operation.

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

true for a normal dispose operation; false to finalize the handle.

API Level: 3
View Source

Finalize()

Destructor of the MessagePort class.

Declaration
C#
Copy
protected void Finalize()
View Source

Listen()

Register the local message port.

Declaration
C#
Copy
public void Listen()
Examples
Copy
MessagePort messagePort = new MessagePort("SenderPort", true); messagePort.MessageReceived += MessageReceivedCallback; messagePort.Listen();
API Level: 3
View Source

Send(Bundle, String, String)

Sends an untrusted message to the message port of a remote application.

Declaration
C#
Copy
public void Send(Bundle message, string remoteAppId, string remotePortName)
Parameters
Type Name Description
Bundle message

The message to be passed to the remote application, the recommended message size is under 4KB.

String remoteAppId

The ID of the remote application.

String remotePortName

The name of the remote message port.

Examples
Copy
MessagePort messagePort = new MessagePort("SenderPort", true); messagePort.MessageReceived += MessageReceivedCallback; messagePort.Listen(); using (var message = new Tizen.Application.Bundle()) { message.AddItem("message", "a_string"); messagePort.Send(message, "ReceiverAppID", "ReceiverPort"); }
API Level: 3
View Source

Send(Bundle, String, String, Boolean)

Sends a message to the message port of a remote application.

Declaration
C#
Copy
public void Send(Bundle message, string remoteAppId, string remotePortName, bool trusted)
Parameters
Type Name Description
Bundle message

The message to be passed to the remote application, the recommended message size is under 4KB.

String remoteAppId

The ID of the remote application.

String remotePortName

The name of the remote message port.

Boolean trusted

If true, it is the trusted message port of remote application, otherwise false.

Examples
Copy
MessagePort messagePort = new MessagePort("SenderPort", true); messagePort.MessageReceived += MessageReceivedCallback; messagePort.Listen(); using (var message = new Tizen.Application.Bundle()) { message.AddItem("message", "a_string"); messagePort.Send(message, "ReceiverAppID", "ReceiverPort", true); }
API Level: 3
View Source

StopListening()

Unregisters the local message port.

Declaration
C#
Copy
public void StopListening()
Examples
Copy
MessagePort messagePort = new MessagePort("SenderPort", true); messagePort.MessageReceived += MessageReceivedCallback; messagePort.Listen(); using (var message = new Tizen.Application.Bundle()) { message.AddItem("message", "a_string"); messagePort.Send(message, "ReceiverAppID", "ReceiverPort"); } messagePort.StopListening();
API Level: 3

Events

View Source

MessageReceived

Called when a message is received.

Declaration
C#
Copy
public event EventHandler<MessageReceivedEventArgs> MessageReceived
Event Type
Type Description
EventHandler<MessageReceivedEventArgs>
Examples
Copy
MessagePort messagePort = new MessagePort("SenderPort", true); messagePort.MessageReceived += MessageReceivedCallback; static void MessageReceivedCallback(object sender, MessageReceivedEventArgs e) { Console.WriteLine("Message Received "); if (e.Remote.AppId != null) { Console.WriteLine("from :"+e.Remote.AppId); } }
API Level: 3

Extension Methods