Beispiel #1
0
 /// <summary>
 /// 向指定客户端发送字符串数据
 /// </summary>
 /// <param name="iClient"></param>
 /// <param name="msg"></param>
 /// <param name="isHexString"></param>
 public void SendData(IClient iClient, string msg, bool isHexString = false)
 {
     byte[] data;
     if (isHexString)
     {
         data = ConvertStringManager.StringToHexByteArray(msg);
     }
     else
     {
         data = Encoding.Default.GetBytes(msg);
     }
     SendData(iClient, data);
 }
Beispiel #2
0
        /// <summary>
        /// 向指定IP和端口客户端发送字符串数据
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="port"></param>
        /// <param name="msg"></param>
        /// <param name="isHexString"></param>
        public void SendData(string ip, int port, string msg, bool isHexString = false)
        {
            IClient iClient = FindIClient(ip, port);

            if (iClient == null)
            {
                return;
            }
            byte[] data;
            if (isHexString)
            {
                data = ConvertStringManager.StringToHexByteArray(msg);
            }
            else
            {
                data = Encoding.Default.GetBytes(msg);
            }
            SendData(iClient, data);
        }