Class MessagePort

    Definition

    Namespace:
    Tizen.Applications.Messages
    Assembly:
    Tizen.Applications.MessagePort.dll

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

    public class MessagePort : IDisposable
    Inheritance
    object
    MessagePort
    Implements
    System.IDisposable
    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, bool)

    Initializes the instance of the MessagePort class.

    Declaration
    public MessagePort(string portName, bool trusted)
    Parameters
    Type Name Description
    string portName

    The name of the local message port.

    bool trusted

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

    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.

    Examples
    MessagePort messagePort = new MessagePort("SenderPort", true);
    Exceptions
    Type Condition
    System.ArgumentException

    Thrown when portName is null or empty.

    Properties

    View Source

    Listening

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

    Declaration
    public bool Listening { get; }
    Property Value
    Type Description
    bool
    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.

    View Source

    PortName

    The name of the local message port.

    Declaration
    public string PortName { get; }
    Property Value
    Type Description
    string
    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.

    View Source

    Trusted

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

    Declaration
    public bool Trusted { get; }
    Property Value
    Type Description
    bool
    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.

    Methods

    View Source

    Dispose()

    Releases all resources used by the MessagePort class.

    Declaration
    public void Dispose()
    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.

    View Source

    Dispose(bool)

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

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

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

    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.

    View Source

    ~MessagePort()

    Destructor of the MessagePort class.

    Declaration
    protected ~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.

    View Source

    Listen()

    Register the local message port.

    Declaration
    public void Listen()
    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.

    Examples
    MessagePort messagePort = new MessagePort("SenderPort", true);
    messagePort.MessageReceived += MessageReceivedCallback;
    messagePort.Listen();
    Exceptions
    Type Condition
    System.InvalidOperationException

    Thrown when portName is already used, when there is an I/O error.

    System.ArgumentException

    Thrown when there is an invalid parameter.

    System.OutOfMemoryException

    Thrown when out of memory.

    View Source

    Send(Bundle, string, string, bool)

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

    Declaration
    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.

    bool trusted

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

    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.

    Examples
    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);
    }
    Exceptions
    Type Condition
    System.InvalidOperationException

    Thrown when there is an I/O error, when the port is not found.

    System.ArgumentException

    Thrown when there is an invalid parameter.

    System.OutOfMemoryException

    Thrown when out of memory.

    System.ArgumentOutOfRangeException

    Thrown when message has exceeded the maximum limit(4KB).

    System.UnauthorizedAccessException

    Thrown when the remote application is not signed with the same certificate.

    View Source

    Send(Bundle, string, string)

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

    Declaration
    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.

    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.

    Examples
    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");
    }
    Exceptions
    Type Condition
    System.InvalidOperationException

    Thrown when there is an I/O error, when the port is not found.

    System.ArgumentException

    Thrown when there is an invalid parameter.

    System.OutOfMemoryException

    Thrown when out of memory.

    System.ArgumentOutOfRangeException

    Thrown when message has exceeded the maximum limit(4KB).

    View Source

    StopListening()

    Unregisters the local message port.

    Declaration
    public void StopListening()
    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.

    Examples
    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();
    Exceptions
    Type Condition
    System.InvalidOperationException

    Thrown when messageport is already stopped, when there is an I/O error, when the port is not found.

    System.ArgumentException

    Thrown when there is an invalid parameter.

    System.OutOfMemoryException

    Thrown when out of memory.

    Events

    View Source

    MessageReceived

    Called when a message is received.

    Declaration
    public event EventHandler<MessageReceivedEventArgs> MessageReceived
    Event Type
    Type Description
    System.EventHandler<TEventArgs><MessageReceivedEventArgs>
    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.

    Examples
    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);
        }
    }

    Implements

    System.IDisposable
    • View Source
    Back to top Copyright © 2016-2024 Samsung
    Generated by DocFX