private void ClientOnReceiveMessage(PipeConnection p_Connection, PipeMessage p_Message) { if (ClientMessage != null) { ClientMessage(p_Connection, p_Message); } }
private void OnReceiveMessage(PipeConnection p_Connection, PipeMessage p_Message) { if (ServerMessage != null) { ServerMessage(p_Connection, p_Message); } }
private void ClientOnConnected(PipeConnection p_Connection) { if (ClientConnected != null) { ClientConnected(p_Connection); } }
private void OnDisconnected(PipeConnection p_Connection) { if (Disconnected != null) { Disconnected(p_Connection); } m_Disconnected.Set(); if (AutoReconnect && !m_ClosedExplicitly) { Start(); } }
private void ClientOnDisconnected(PipeConnection p_Connection) { if (p_Connection == null) { return; } lock (m_Connections) m_Connections.Remove(p_Connection); if (ClientDisconnected != null) { ClientDisconnected(p_Connection); } }
private void ListenSync() { var s_Handshake = PipeClientFactory.Connect(m_PipeName); var s_DataPipeName = s_Handshake.ReadMessage(); s_Handshake.Close(); var s_DataPipe = PipeClientFactory.CreateAndConnectPipe(s_DataPipeName.Content); m_Connection = ConnectionFactory.CreateConnection(s_DataPipe); m_Connection.Disconnected += OnDisconnected; m_Connection.ReceiveMessage += OnReceiveMessage; m_Connection.Open(); m_Connected.Set(); }
private void WaitForConnection(string p_PipeName) { NamedPipeServerStream s_HandshakePipe = null; NamedPipeServerStream s_DataPipe = null; PipeConnection s_Connection = null; var s_ConnectionPipeName = GetNextConnectionPipeName(p_PipeName); try { s_HandshakePipe = PipeServerFactory.CreateAndConnectPipe(p_PipeName); var s_HandshakeWrapper = new PipeStreamWrapper(s_HandshakePipe); s_HandshakeWrapper.WriteMessage(new PipeMessage() { Module = "SM", Type = "HS", Content = s_ConnectionPipeName }); s_HandshakeWrapper.WaitForPipeDrain(); s_HandshakeWrapper.Close(); s_DataPipe = PipeServerFactory.CreatePipe(s_ConnectionPipeName); s_DataPipe.WaitForConnection(); s_Connection = ConnectionFactory.CreateConnection(s_DataPipe); s_Connection.ReceiveMessage += ClientOnReceiveMessage; s_Connection.Disconnected += ClientOnDisconnected; s_Connection.Open(); lock (m_Connections) m_Connections.Add(s_Connection); ClientOnConnected(s_Connection); } catch (Exception) { Cleanup(s_HandshakePipe); Cleanup(s_DataPipe); ClientOnDisconnected(s_Connection); } }
private void OnReceiveMessage(PipeConnection p_Connection, PipeMessage p_Message) { if (ServerMessage != null) ServerMessage(p_Connection, p_Message); }
private void OnDisconnected(PipeConnection p_Connection) { if (Disconnected != null) Disconnected(p_Connection); m_Disconnected.Set(); if (AutoReconnect && !m_ClosedExplicitly) Start(); }
private void ClientOnReceiveMessage(PipeConnection p_Connection, PipeMessage p_Message) { if (ClientMessage != null) ClientMessage(p_Connection, p_Message); }
private void ClientOnDisconnected(PipeConnection p_Connection) { if (p_Connection == null) return; lock (m_Connections) m_Connections.Remove(p_Connection); if (ClientDisconnected != null) ClientDisconnected(p_Connection); }
private void ClientOnConnected(PipeConnection p_Connection) { if (ClientConnected != null) ClientConnected(p_Connection); }