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


C# Message.DumpMessage方法代码示例

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


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

示例1: ReadEncrypted

    public string ReadEncrypted(Transceiver connection, string message)
    {
        Logger.log("Encryption hook is decrypting incoming message.", Logger.Verbosity.moderate);
        byte[] bytes = System.Text.Encoding.Unicode.GetBytes(message);
        byte[] decrypted = Decrypt(this._local_cryptor, bytes);
        string final = System.Text.Encoding.Unicode.GetString(decrypted);
        try
        {
            Message test_message = new Message(null, final);
            Logger.log("THE MESSAGE: "+test_message.DumpMessage(), Logger.Verbosity.moderate);
            Logger.log("Type of message is: "+test_message.StringType(), Logger.Verbosity.moderate);
            if(test_message.type == Message.Type.UserToUser)
            {

                /** Test for encrypted middle **/

                Logger.log("Attempting to scrape inner message.", Logger.Verbosity.moderate);

                XmlDocument document  = new XmlDocument();
                document.LoadXml(final);
                XmlNodeList list = document.GetElementsByTagName("Content");
                XmlElement element = (XmlElement)list.Item(0);
                string core = element.InnerText;
                byte[] core_bytes = System.Text.Encoding.Unicode.GetBytes(core);
                byte[] decrypted_bytes = this.Decrypt(this._local_cryptor, core_bytes);
                string cdecrypted = System.Text.Encoding.Unicode.GetString(decrypted_bytes);
                Logger.log("Decrypted inner message: "+cdecrypted, Logger.Verbosity.loud);
                element.InnerXml = cdecrypted;
                return document.InnerXml;
            }
            else
            {
                return final;
            }
        }
        catch(Exception e)
        {
            Logger.log("Decryptor ERROR: "+e.Message+"\n"+e.StackTrace, Logger.Verbosity.moderate);
            return final;
        }
    }
开发者ID:spox,项目名称:irisim,代码行数:41,代码来源:Cryptor.cs

示例2: SendAuthentication

 private bool SendAuthentication(string username, string password)
 {
     this.SendUINotice("Sending authentication information.");
     Message message = new Message();
     message.type = Message.Type.UserToServer;
     message.creator_plugin_hash = this._hash_code;
     message.destination_plugin_hash = this._user_manager_hash;
     Command contents = new Command();
     contents.ctype = "login";
     contents.type = MessageContent.Type.Command;
     contents.AddContent("username", username);
     contents.AddContent("password", password);
     message.content = contents;
     this._controller.connection.Write(message.DumpMessage());
     return true;
 }
开发者ID:spox,项目名称:irisim,代码行数:16,代码来源:Connector.cs

示例3: WriteFilter

 public string WriteFilter(Message message)
 {
     if(message.content.type == BasicContent.Type.Chat)
     {
         try
         {
             string key = (string)this._keys[message.destination_plugin_hash];
             this._remote_cryptor.FromXmlString(key);
             string basemsg = message.DumpMessage();
             XmlDocument document = new XmlDocument();
             document.LoadXml(basemsg);
             XmlNodeList list = document.GetElementsByTagName("Content");
             XmlElement element = (XmlElement)list.Item(0);
             string full = element.InnerXml;
             byte[] full_bytes = System.Text.Encoding.Unicode.GetBytes(full);
             byte[] crypted_bytes = this.Encrypt(this._remote_cryptor, full_bytes);
             string crypted = System.Text.Encoding.Unicode.GetString(crypted_bytes);
             element.InnerText = crypted;
             return document.InnerXml;
         }
         catch(Exception e)
         {
             Logger.log("Error filtering: "+e.Message, Logger.Verbosity.moderate);
             return message.DumpMessage();
         }
     }
     else
     {
         return message.DumpMessage();
     }
 }
开发者ID:spox,项目名称:irisim,代码行数:31,代码来源:Cryptor.cs

示例4: Write

 public void Write(Message message)
 {
     try
     {
         try
         {
             string mod_message = this.filter_writer(message);
             this._plugin_writers(this, mod_message);
         }
         catch
         {
             this._plugin_writers(this, message.DumpMessage());
         }
     }
     catch
     {
         this._connection.Send(Encoding.Unicode.GetBytes(message.DumpMessage()));
     }
 }
开发者ID:spox,项目名称:irisim,代码行数:19,代码来源:Transceiver.cs

示例5: Reader

            private void Reader()
            {
                int buffer_size = 1024;
                int received = 0;
                byte[] buffer = new byte[buffer_size];
                string message_string = "";
                Message message = null;
                IPEndPoint userinfo = null;
                while(this._alive)
                {
                    try
                    {
                        userinfo = (IPEndPoint)this._connection.RemoteEndPoint;
                        Logger.log("Connection alive from: " + userinfo.Address.ToString() +" Code: "+ this.GetHashCode(), Logger.Verbosity.loud);
                    }
                    catch(Exception e)
                    {
                        Logger.log("Connection is alive but not connected. Code: "+this.GetHashCode(), Logger.Verbosity.loud);
                    }

                    if(this._connection.Poll(-1, SelectMode.SelectRead))
                    {
                        message_string = "";
                        message = null;
                        received = 0;
                        if(this._connection.Available > 1)
                        {
                            while(received < this._connection.Available)
                            {
                                received += this._connection.Receive(buffer);
                                message_string += Encoding.Unicode.GetString(buffer);
                            }
                            try
                            {
                                message = new Message(this, this._plugin_readers(this, message_string));
                            }
                            catch(Exception e)
                            {
                                message = new Message(this, message_string);
                            }
                            try
                            {
                                Logger.log("Transceiver: Message received: "+message.DumpMessage(), Logger.Verbosity.moderate);
                                this._message_processor(message);
                                Logger.log("Transceiver: Received message and properly processed. ("+this.GetHashCode()+")", Logger.Verbosity.moderate);
                            }
                            catch(Exception e)
                            {
                                Logger.log("Failed to process received message. "+e.Message+"\n"+e.StackTrace+" "+message_string, Logger.Verbosity.moderate);
                            }
                        }
                        else
                        {
                            Logger.log("Connection to client lost. Code: "+this.GetHashCode(), Logger.Verbosity.moderate);
                            this._alive = false;
                            // Notification needs to be done using a thread so we
                            // don't end up in a deadlock.
                            (new Thread(new ThreadStart(this.NotifyDisconnection))).Start();
                        }
                    }
                    if(!this._connection.Connected)
                    {
                        Logger.log("Connection is no longer open.", Logger.Verbosity.moderate);
                        break;
                    }
                }
            }
开发者ID:spox,项目名称:irisim,代码行数:67,代码来源:Transceiver.cs

示例6: SendKey

 private void SendKey(Transceiver connection, User request, string userPluginHash)
 {
     string publickey;
     string username;
     Message message = new Message();
     message.creator_plugin_hash = this._hash_code;
     message.type = Message.Type.ServerToUser;
     if(request == null)
     {
         publickey = this._server_public_key;
         username = "server";
     }
     else
     {
         publickey = (string)this._user_keys[request.connection];
         username = request.username;
     }
     Response content = new Response();
     message.content = content;
     content.type = BasicContent.Type.Response;
     content.rtype = "success";
     content.AddContent("command", "publickey");
     content.AddContent("username", username);
     content.AddContent("publickey", publickey);
     string mess = message.DumpMessage();
     connection.Write(mess);
 }
开发者ID:spox,项目名称:irisim,代码行数:27,代码来源:CryptManager.cs

示例7: ProcessDirectedMessage

 private void ProcessDirectedMessage(Message message)
 {
     try
     {
         Information content = (Information)message.content;
         string xml = message.DumpMessage();
         Logger.log(xml, Logger.Verbosity.moderate);
         XmlDocument document = new XmlDocument();
         document.LoadXml(xml);
         XmlNodeList list = document.GetElementsByTagName("Value");
         XmlElement element = (XmlElement)list.Item(0);
         if(element.HasAttribute("name") && element.GetAttribute("name") == "publickey")
         {
             string key = element.InnerXml;
             this._user_keys[message.origin] = key;
             this.SendKey(message.origin, null, message.creator_plugin_hash);
             Logger.log("Sending server public key to client.", Logger.Verbosity.moderate);
             message.origin.plugin_writers += this.WriteEncryptedMessage;
             message.origin.plugin_readers += this.ReadEncryptedMessage;
             Logger.log("Encryption hooks have been added to transceiver.", Logger.Verbosity.moderate);
         }
     }
     catch(Exception ex)
     {
         try
         {
             Command content = (Command)message.content;
             if(content.ctype == "publickey" && content.Exists("username"))
             {
                 this.PublicKeyRequest(message, content.GetContent("username"));
             }
             else
             {
                 throw new Exception("User has not been logged in.");
             }
         }
         catch(Exception e)
         {
             Logger.log("Message type received is not supported. Ignoring.: "+e.Message+" : "+e.StackTrace, Logger.Verbosity.moderate);
         }
     }
 }
开发者ID:spox,项目名称:irisim,代码行数:42,代码来源:CryptManager.cs


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