public static void doDemo(IChannel _channel) { if (_channel.Socket.Connected) { Beetle.StringMessage _bsm = new Beetle.StringMessage(); _bsm.Value = "CreateClient"; _channel.Send(_bsm); } }
public static int Send(IChannel _channel, string vStr, bool hasCrLf) { //doDemo(_channel); if (string.IsNullOrEmpty(vStr)) { return(0); } if (_channel.IsDisposed) { return(-1); } bool _ok = false; // 处理 CrLf bool _CrLf = vStr.EndsWith("&CrLf"); if (_CrLf) // 优先 { vStr = vStr.Replace("&CrLf", ""); vStr = vStr + "\r\n"; //vStr = vStr.Replace("~", ","); } else if (hasCrLf) { vStr = vStr + "\r\n"; } try { Beetle.StringMessage _bsm = new Beetle.StringMessage(); _bsm.Value = vStr; _ok = _channel.Send(_bsm); } catch (Exception e_) { MessageBox.Show("-102:" + e_.Message); //Console.WriteLine(e_.Message); return(-102); } return(_ok ? vStr.Length : 0); }