/// <summary> /// 通知服务器客户端即将退出 /// </summary> public static void ClosePipe() { if (pipeClient != null) { m_StreamString.WriterString("close"); m_StreamString = null; pipeClient.Close(); pipeClient = null; } }
/// <summary> /// 启动客户端,连接服务器,只允许连接一次 /// </summary> /// <returns></returns> public static bool StartConnection() { try { if (pipeClient == null) { pipeClient = new NamedPipeClientStream(".", ServerName, PipeDirection.InOut, PipeOptions.None, TokenImpersonationLevel.Impersonation); pipeClient.Connect(2000); m_StreamString = new StreamString(pipeClient); } } catch (Exception exception) { //Environment.Exit(0); pipeClient = null; throw new Exception("未启动服务器端" + exception.Message); } return(true); }
public StringToStream(StreamString ss, JObject jo) { }
public StringToStream(StreamString ss, string contents) { Contents = contents; streamString = ss; }