public void StartReceive() { if (false == IsConnected()) { ForceDisconnect(CloseReason.NotConnected); m_bReceiving.ForceFalse(); return; } try { bool willRaiseEvent = m_socket.ReceiveAsync(m_saeaReciver); m_bReceiving.ForceTrue(); // I/O 작업이 동기적으로 완료된 경우 false를 반환합니다. // 이 경우에는 e 매개 변수에서 SocketAsyncEventArgs.Completed 이벤트가 발생하지 않으며, // 메서드 호출이 반환된 직후 매개 변수로 전달된 e 개체를 검사하여 작업 결과를 검색할 수 있습니다. if (false == willRaiseEvent) { ProcessReceive(m_saeaReciver); } } catch (Exception ex) { OnError(string.Format("StartReceive {0}", ex.ToString())); m_bReceiving.ForceFalse(); ForceDisconnect(CloseReason.SocketError); return; } }
// 서버에서 강제로 제거 용 public void ForceDisconnect(CloseReason reason = CloseReason.Unknown) { try { if (reason == CloseReason.RemoteClose) { Logger.Debug("ForceDisconnect: {0}", reason); } else { Logger.Log("ForceDisconnect: {0}", reason); } if (true == m_bClosing.SetTrue()) { // [ MUSTBE BY KWJ ] : 20150212 // OnDisconnected 메소드 처리 내용 수정하자. // 굳이 세션메니저에서 처리할 내용인가?에 대해서 다시 생각해보자. OnDisconnected(reason); OnClose(); Close(); m_bClosed.ForceTrue(); } } catch (Exception ex) { Logger.Log(ex.ToString()); } }