当前位置: 首页>>代码示例>>C#>>正文


C# Message.GetArg方法代码示例

本文整理汇总了C#中Message.GetArg方法的典型用法代码示例。如果您正苦于以下问题:C# Message.GetArg方法的具体用法?C# Message.GetArg怎么用?C# Message.GetArg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Message的用法示例。


在下文中一共展示了Message.GetArg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CatMethodHandler

 /// <summary>
 /// concatenates two strings sent by the client and returns the result
 /// </summary>
 /// <param name="member">Member of the interface which message contains</param>
 /// <param name="message">arguments sent by the client</param>
 public void CatMethodHandler(InterfaceMember member, Message message)
 {
     MsgArg msg = message.GetArg(0);
     MsgArg msg2 = message.GetArg(1);
     string val = msg.Value as string;
     string val2 = msg2.Value as string;
     App.OutputLine("//////////////////////////////////////////////////////////////////");
     App.OutputLine("Cat Method was called by '" + message.Sender + "' given '" + val +
                     "' and '" + val2 + "' as arguments.");
     string ret = val + val2;
     object[] obj = { ret };
     MsgArg msgReply = new MsgArg("s", obj);
     this.BusObject.MethodReply(message, new MsgArg[] { msgReply });
     App.OutputLine("The value '" + ret + "' was returned to '" + message.Sender + "'.");
 }
开发者ID:peterdocter,项目名称:Coco2dxDemo,代码行数:20,代码来源:BasicServiceBusObject.cs

示例2: PingMethodHandler

        /// <summary>
        /// Responds to a ping request.
        /// </summary>
        /// <param name="member">The parameter is not used.</param>
        /// <param name="message">arguments sent by the client</param>
        private void PingMethodHandler(InterfaceMember member, Message message)
        {
            string output = message.GetArg(0).Value as string;

            App.OutputLine(string.Format("Ping : {0}", output));
            App.OutputLine(string.Format("Reply : {0}", output));

            object[] args = { output };

            MsgArg msgReply = new MsgArg("s", args);
            this.BusObject.MethodReply(message, new MsgArg[] { msgReply });
        }
开发者ID:peterdocter,项目名称:Coco2dxDemo,代码行数:17,代码来源:SecureBusObject.cs

示例3: SayHiHandler

 public void SayHiHandler(InterfaceMember member, Message message)
 {
     Assert.AreEqual("hello", message.GetArg(0).Value.ToString());
     MsgArg retArg = new MsgArg("s", new object[] { "aloha" });
     try
     {
         // BUGBUG: Throws exception saying signature of the msgArg is not what was expected, but its correct.
         this.busObject.MethodReplyWithQStatus(message, QStatus.ER_OK);
     }
     catch (Exception ex)
     {
     #if DEBUG
         string err = AllJoynException.GetErrorMessage(ex.HResult);
     #else
         QStatus err = AllJoynException.FromCOMException(ex.HResult);
     #endif
         Assert.IsFalse(true);
     }
 }
开发者ID:nacimiento,项目名称:alljoyn_core,代码行数:19,代码来源:BusObjectTests.cs

示例4: CatHandler

 public void CatHandler(InterfaceMember member, Message message)
 {
     string ret = message.GetArg(0).Value.ToString() + message.GetArg(1).Value.ToString();
     MsgArg retArg = new MsgArg("s", new object[] { ret });
     this.busObject.MethodReply(message, new MsgArg[] { retArg });
 }
开发者ID:nacimiento,项目名称:alljoyn_core,代码行数:6,代码来源:BusObjectTests.cs

示例5: NameChangedSignalHandler

 /// <summary>
 /// called when a signal has been sent from the signal service indicated 'name' property has 
 /// changed. It prints out new value to UI
 /// </summary>
 /// <param name="member">Interface member for signal received</param>
 /// <param name="path">path to the source of the signal</param>
 /// <param name="msg">new value of the 'name' property</param>
 public void NameChangedSignalHandler(InterfaceMember member, string path, Message msg)
 {
     MsgArg msgArg = msg.GetArg(0);
     string newName = msgArg.Value as string;
     App.OutputLine(string.Empty);
     App.OutputLine("/////////////////////////////Name Change Signal/////////////////////////////////");
     App.OutputLine("A Name Changed signal was recieved from '" + SignalConsumerGlobals.WellKnownServiceName + path + "' with a new value of '" + newName + "'");
 }
开发者ID:peterdocter,项目名称:Coco2dxDemo,代码行数:15,代码来源:SignalConsumerBusListener.cs

示例6: ChatSignalHandler

        /// <summary>
        /// Called when another session application sends a chat signal containing a message which
        /// is printed out to the user.
        /// </summary>
        /// <param name="member">Method or signal interface member entry.</param>
        /// <param name="srcPath">Object path of signal emitter.</param>
        /// <param name="message">The received message.</param>
        private void ChatSignalHandler(InterfaceMember member, string srcPath, Message message)
        {
            if (this.ChatEcho)
            {
                string output = string.Format("RX message from {0}[{1}]: {2}", message.Sender, message.SessionId, message.GetArg(0).Value.ToString());

                this.sessionOps.Output(output);
            }
        }
开发者ID:peterdocter,项目名称:Coco2dxDemo,代码行数:16,代码来源:MyBusObject.cs

示例7: Cat

 /// <summary>
 /// Concatenate the two string arguments and return the result to the caller
 /// </summary>
 /// <param name="member">Method interface member entry.</param>
 /// <param name="message">The received method call message containing the two strings
 /// to concatenate</param>
 public void Cat(InterfaceMember member, Message message)
 {
     try
     {
         string arg1 = message.GetArg(0).Value as string;
         string arg2 = message.GetArg(1).Value as string;
         MsgArg retArg = new MsgArg("s", new object[] { arg1 + arg2 });
         this.busObject.MethodReply(message, new MsgArg[] { retArg });
         this.DebugPrint("Method Reply successful (ret=" + arg1 + arg2 + ")");
     }
     catch (Exception ex)
     {
         var errMsg = AllJoynException.GetErrorMessage(ex.HResult);
         this.DebugPrint("Method Reply unsuccessful: " + errMsg);
     }
 }
开发者ID:peterdocter,项目名称:Coco2dxDemo,代码行数:22,代码来源:ServiceBusObject.cs

示例8: OpenStreamAsync

        /// <summary>
        /// On the first signal received from the service open a stream for writing the data to a file.
        /// </summary>
        /// <param name="message">The received message.</param>
        private async Task<bool> OpenStreamAsync(Message message)
        {
            try
            {
                string fileName = Path.GetFileName(message.GetArg(0).Value as string);

                if (!string.IsNullOrEmpty(fileName))
                {
                    StorageFile file = await this.Folder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
                    Stream stream = await file.OpenStreamForWriteAsync();
                    this.Writer = new BinaryWriter(stream);
                }
            }
            catch (Exception ex)
            {
                App.OutputLine("An error occurred while opening the file.");
                App.OutputLine("Error: " + ex.Message);
                this.FileWriteError = true;
            }

            return this.Writer != null;
        }
开发者ID:peterdocter,项目名称:Coco2dxDemo,代码行数:26,代码来源:FileTransferBusObject.cs

示例9: FileTransfer

        /// <summary>
        /// Consumes 'FileTransfer' signals form the service and extracts the data to write to an 
        /// output file.
        /// </summary>
        /// <param name="member">Method or signal interface member entry.</param>
        /// <param name="srcPath">Object path of signal emitter.</param>
        /// <param name="message">The received message.</param>
        private async void FileTransfer(InterfaceMember member, string srcPath, Message message)
        {
            UInt32 currentIndex = (UInt32)message.GetArg(1).Value;

            while (currentIndex != this.lastIndex + 1)
            {
                await Task.Yield();
            }

            byte[] data = message.GetArg(2).Value as byte[];

            if (null != data)
            {
                if (0 != data.Count())
                {
                    string mess = string.Format("Array Num : {0} Size : {1}", currentIndex, data.Count());

                    App.OutputLine(mess);

                    bool openSuccess = null != this.Writer;

                    if (!openSuccess && 1 == currentIndex)
                    {
                        this.FileWriteError = false;
                        openSuccess = await this.OpenStreamAsync(message);
                    }

                    if (openSuccess)
                    {
                        mess = string.Format("Writing Array Num : {0}", currentIndex);
                        App.OutputLine(mess);
                        this.WriteToFile(data);
                    }
                    else
                    {
                        this.FileWriteError = true;
                        mess = string.Format("File was not open for writing array {0}.", currentIndex);
                        App.OutputLine(mess);
                    }
                }
                else
                {
                    // Done with this transfer prepare for another.
                    this.lastIndex = 0;

                    if (this.FileWriteError)
                    {
                        App.OutputLine("File transfer was unsuccessful!", true);
                    }
                    else
                    {
                        App.OutputLine("The file was transfered successfully.", true);
                    }

                    if (null != this.Writer)
                    {
                        this.Writer.Flush();
                        this.Writer.Dispose();
                        this.Writer = null;
                    }
                }
            }
            else
            {
                App.OutputLine("Unable to retrieve data array from message arg 2.");
                this.FileWriteError = true;
            }

            this.lastIndex = currentIndex;
        }
开发者ID:peterdocter,项目名称:Coco2dxDemo,代码行数:77,代码来源:FileTransferBusObject.cs

示例10: HandleExceptionMsg

 void HandleExceptionMsg(Message msg)
 {
     if (logNetworkExceptions) {
         var errorMsg = "An exception was received from the server when sending message: " + msg.GetArg<string> (1) + " " + msg.GetArg<string> (2) + "\r\n";
         Debug.LogError (errorMsg);
     }
 }
开发者ID:simonwittber,项目名称:netwrok-client,代码行数:7,代码来源:Connection.cs

示例11: ProcessMessage

 void ProcessMessage(Message msg)
 {
     switch (msg.name) {
     case "return":
         HandleReturnMsg (msg);
         break;
     case "said":
         HandleRoomMsg (msg);
         break;
     case "whispers":
         HandleUserMsg (msg);
         break;
     case "welcome":
         UID = msg.GetArg<string> (0);
         if (OnWelcome != null)
             OnWelcome ();
         break;
     case "exception":
         HandleExceptionMsg (msg);
         break;
     default:
         HandleSystemMessage (msg);
         break;
     }
 }
开发者ID:simonwittber,项目名称:netwrok-client,代码行数:25,代码来源:Connection.cs

示例12: HandleUserMsg

 void HandleUserMsg(Message msg)
 {
     var cmd = msg.GetArg<string> (0);
     var uid = msg.GetArg<string> (1);
     if (OnUserMessage != null)
         OnUserMessage (cmd, uid, msg);
 }
开发者ID:simonwittber,项目名称:netwrok-client,代码行数:7,代码来源:Connection.cs

示例13: HandleRoomMsg

 void HandleRoomMsg(Message msg)
 {
     var cmd = msg.GetArg<string> (0);
     var uid = msg.GetArg<string> (1);
     var room = msg.GetArg<string> (2);
     if (OnRoomMessage != null)
         OnRoomMessage (room, uid, cmd, msg);
 }
开发者ID:simonwittber,项目名称:netwrok-client,代码行数:8,代码来源:Connection.cs

示例14: HandleReturnMsg

 void HandleReturnMsg(Message msg)
 {
     var fn = msg.GetArg<string> (0);
     var id = msg.GetArg<string> (1);
     var success = msg.GetArg<bool> (2);
     if (requests.ContainsKey (id)) {
         var req = requests [id];
         if (success) {
             req.Result = msg.GetArg<object> (3);
         } else {
             req.Error = msg.GetArg<string> (3);
         }
         req.isDone = true;
         requests.Remove (id);
     } else {
         Debug.LogError ("Invalid request ID in return msg: " + fn + " " + id);
     }
 }
开发者ID:simonwittber,项目名称:netwrok-client,代码行数:18,代码来源:Connection.cs

示例15: ChatSignalHandler

 /// <summary>
 /// The method to handle a signal. If the message is for the active chat channel this device is
 /// on then the message is forwarded to the user interface page.
 /// </summary>
 /// <param name="member">The parameter is not used.</param>
 /// <param name="path">The parameter is not used.</param>
 /// <param name="msg">The msg from the other end.</param>
 public void ChatSignalHandler(InterfaceMember member, string path, Message msg)
 {
     if (this.hostPage != null && msg != null && msg.SessionId == this.hostPage.SessionId &&
         msg.Sender != msg.RcvEndpointName)
     {
         string sender = msg.Sender;
         var content = msg.GetArg(0).Value;
         if (content != null)
         {
             this.hostPage.OnChat(this.hostPage.SessionId, sender + ": ", content.ToString());
         }
     }
 }
开发者ID:peterdocter,项目名称:Coco2dxDemo,代码行数:20,代码来源:ChatSessionObject.cs


注:本文中的Message.GetArg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。