/// <summary>
 /// 获得消息包的字节流
 /// </summary>
 /// <param name="message">要打包的消息对象</param>
 /// <returns></returns>
 public static PackedNetworkMessage[] BuildNetworkMessage(IPMessager.Entity.Message message)
 {
     if (message.ExtendMessageBytes != null)
     {
         return(BuildNetworkMessage(
                    message.HostAddr,
                    message.PackageNo,
                    message.Command,
                    message.Options,
                    message.UserName,
                    message.HostName,
                    message.NormalMsgBytes,
                    message.ExtendMessageBytes
                    ));
     }
     else
     {
         return(BuildNetworkMessage(
                    message.HostAddr,
                    message.PackageNo,
                    message.Command,
                    message.Options,
                    message.UserName,
                    message.HostName,
                    System.Text.Encoding.Unicode.GetBytes(message.NormalMsg),
                    System.Text.Encoding.Unicode.GetBytes(message.ExtendMessage)
                    ));
     }
 }
Exemple #2
0
        /// <summary>
        /// 获得消息包的字节流
        /// </summary>
        /// <param name="message">要打包的消息对象</param>
        /// <returns></returns>
        public static Entity.PackedNetworkMessage BuildNetworkMessage(IPMessager.Entity.Message message)
        {
            if (message.NormalMsgBytes == null)
            {
                if (string.IsNullOrEmpty(message.NormalMsg))
                {
                    message.NormalMsgBytes = new byte[] { }
                }
                ;
                else
                {
                    message.NormalMsgBytes = System.Text.Encoding.Default.GetBytes(message.NormalMsg);
                }
            }
            if (message.ExtendMessageBytes == null)
            {
                if (string.IsNullOrEmpty(message.ExtendMessage))
                {
                    message.ExtendMessageBytes = new byte[] { }
                }
                ;
                else
                {
                    message.ExtendMessageBytes = System.Text.Encoding.Default.GetBytes(message.ExtendMessage);
                }
            }

            return(BuildNetworkMessage(
                       message.HostAddr,
                       message.PackageNo,
                       message.Command,
                       message.Options,
                       message.UserName,
                       message.HostName,
                       message.NormalMsgBytes,
                       message.ExtendMessageBytes
                       ));
        }