Esempio n. 1
0
 /// <summary>
 /// 通知服务器客户端即将退出
 /// </summary>
 public static void ClosePipe()
 {
     if (pipeClient != null)
     {
         m_StreamString.WriterString("close");
         m_StreamString = null;
         pipeClient.Close();
         pipeClient = null;
     }
 }
Esempio n. 2
0
        /// <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);
        }
Esempio n. 3
0
 public StringToStream(StreamString ss, JObject jo)
 {
 }
Esempio n. 4
0
 public StringToStream(StreamString ss, string contents)
 {
     Contents     = contents;
     streamString = ss;
 }