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#Copypublic 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
Declaration
C#Copypublic 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
CopyMessagePort messagePort = new MessagePort("SenderPort", true);
API Level: 3
Properties
Declaration
C#Copypublic bool Listening { get; }
Property Value
Type | Description |
---|---|
Boolean |
API Level: 3
Declaration
C#Copypublic string PortName { get; }
Property Value
Type | Description |
---|---|
String |
API Level: 3
Declaration
C#Copypublic bool Trusted { get; }
Property Value
Type | Description |
---|---|
Boolean |
API Level: 3
Methods
Declaration
C#Copypublic void Dispose()
API Level: 3
Dispose(Boolean)
Releases the unmanaged resources used by the MessagePort class specifying whether to perform a normal dispose operation.
Declaration
C#Copyprotected 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
Declaration
C#Copyprotected void Finalize()
Declaration
C#Copypublic void Listen()
Examples
CopyMessagePort messagePort = new MessagePort("SenderPort", true); messagePort.MessageReceived += MessageReceivedCallback; messagePort.Listen();
API Level: 3
Send(Bundle, String, String)
Sends an untrusted message to the message port of a remote application.
Declaration
C#Copypublic 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
CopyMessagePort 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
Send(Bundle, String, String, Boolean)
Sends a message to the message port of a remote application.
Declaration
C#Copypublic 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
CopyMessagePort 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
Declaration
C#Copypublic void StopListening()
Examples
CopyMessagePort 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
Declaration
C#Copypublic event EventHandler<MessageReceivedEventArgs> MessageReceived
Event Type
Type | Description |
---|---|
EventHandler<MessageReceivedEventArgs> |
Examples
CopyMessagePort 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); } }