From 2a6be2cfe72454df7aaef1b016da03b80924d8c3 Mon Sep 17 00:00:00 2001 From: Seunghyun Choi Date: Wed, 27 Apr 2016 17:23:05 +0900 Subject: [PATCH] [MessagePort] Add Exception and example code Change-Id: Iae467bf888f1c3ae5abb6dc0126feac63106134b Signed-off-by: Seunghyun Choi --- .../Tizen.Applications.Messages/MessagePort.cs | 65 ++++++++++++++++++++++ .../MessagePortErrorFactory.cs | 8 +++ .../MessageReceivedEventArgs.cs | 8 +++ .../Tizen.Applications.Messages/RemoteValues.cs | 8 +++ 4 files changed, 89 insertions(+) diff --git a/Tizen.Applications/Tizen.Applications.Messages/MessagePort.cs b/Tizen.Applications/Tizen.Applications.Messages/MessagePort.cs index 2cd1d8d..2624dc7 100755 --- a/Tizen.Applications/Tizen.Applications.Messages/MessagePort.cs +++ b/Tizen.Applications/Tizen.Applications.Messages/MessagePort.cs @@ -1,3 +1,11 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + using System; using System.Collections.Generic; @@ -35,6 +43,10 @@ namespace Tizen.Applications.Messages /// /// The name of the local message port /// If true is the trusted message port of application, otherwise false + /// Thrown when portName is null or empty + /// + /// MessagePort messagePort = new MessagePort("SenderPort", true); + /// public MessagePort(string portName, bool trusted) { if (String.IsNullOrEmpty(portName)) @@ -56,6 +68,17 @@ namespace Tizen.Applications.Messages /// /// Called when a message is received. /// + /// + /// 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); + /// } + /// } + /// public event EventHandler MessageReceived; /// @@ -93,6 +116,12 @@ namespace Tizen.Applications.Messages /// /// Register the local message port. /// + /// Thrown when portName is already used, when there is an invalid parameter, when out of memory, when there is an I/O error + /// + /// MessagePort messagePort = new MessagePort("SenderPort", true); + /// messagePort.MessageReceived += MessageReceivedCallback; + /// messagePort.Listen(); + /// public void Listen() { lock (s_lock) @@ -135,6 +164,18 @@ namespace Tizen.Applications.Messages /// /// Unregisters the local message port. /// + /// Thrown when messageport is already stopped, when there is an invalid parameter, when the port is not found, when out of memory, when there is an I/O error + /// + /// 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"); + /// } + /// messageProt.StopListening(); + /// public void StopListening() { if (!_listening) @@ -165,6 +206,18 @@ namespace Tizen.Applications.Messages /// The message to be passed to the remote application, the recommended message size is under 4KB /// The ID of the remote application /// The name of the remote message port + /// Thrown when there is an invalid parameter, when the port is not found, when out of memory, when there is an I/O error + /// Thrown when message has exceeded the maximum limit(4KB) + /// + /// 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"); + /// } + /// public void Send(Bundle message, string remoteAppId, string remotePortName) { Send(message, remoteAppId, remotePortName, false); @@ -177,6 +230,18 @@ namespace Tizen.Applications.Messages /// The ID of the remote application /// The name of the remote message port /// If true the trusted message port of remote application otherwise false + /// Thrown when there is an invalid parameter, when the port is not found, when out of memory, when there is an I/O error + /// Thrown when message has exceeded the maximum limit(4KB) + /// + /// 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); + /// } + /// public void Send(Bundle message, string remoteAppId, string remotePortName, bool trusted) { if (!_listening) diff --git a/Tizen.Applications/Tizen.Applications.Messages/MessagePortErrorFactory.cs b/Tizen.Applications/Tizen.Applications.Messages/MessagePortErrorFactory.cs index ed74f34..e209240 100755 --- a/Tizen.Applications/Tizen.Applications.Messages/MessagePortErrorFactory.cs +++ b/Tizen.Applications/Tizen.Applications.Messages/MessagePortErrorFactory.cs @@ -1,3 +1,11 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + using System; using Tizen.Internals.Errors; diff --git a/Tizen.Applications/Tizen.Applications.Messages/MessageReceivedEventArgs.cs b/Tizen.Applications/Tizen.Applications.Messages/MessageReceivedEventArgs.cs index 626886a..1ee8842 100755 --- a/Tizen.Applications/Tizen.Applications.Messages/MessageReceivedEventArgs.cs +++ b/Tizen.Applications/Tizen.Applications.Messages/MessageReceivedEventArgs.cs @@ -1,3 +1,11 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + using System; namespace Tizen.Applications.Messages diff --git a/Tizen.Applications/Tizen.Applications.Messages/RemoteValues.cs b/Tizen.Applications/Tizen.Applications.Messages/RemoteValues.cs index a2890a9..19ccdc6 100755 --- a/Tizen.Applications/Tizen.Applications.Messages/RemoteValues.cs +++ b/Tizen.Applications/Tizen.Applications.Messages/RemoteValues.cs @@ -1,3 +1,11 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + namespace Tizen.Applications.Messages { /// -- 2.7.4