/// <summary> /// Begins the process of receiving a message from the client. /// This method must manually be called to Begin receiving data /// </summary> public void BeginReceive() { try { if (Connection != null) { // Reset Buffer offset back to the original allocated offset BufferDataToken token = ReadEventArgs.UserToken as BufferDataToken; ReadEventArgs.SetBuffer(token.BufferOffset, token.BufferBlockSize); // Begin Receiving if (!Connection.ReceiveAsync(ReadEventArgs)) { ProcessReceive(); } } } catch (ObjectDisposedException) { if (!DisconnectEventCalled) { // Disconnect user DisconnectEventCalled = true; OnDisconnect?.Invoke(this); } } catch (SocketException e) { HandleSocketError(e.SocketErrorCode); } }
/// <summary> /// Begins the process of receiving a message from the client. /// This method must manually be called to Begin receiving data /// </summary> public void BeginReceive() { try { if (Connection != null) { // Reset Buffer offset back to the original allocated offset BufferDataToken token = ReadEventArgs.UserToken as BufferDataToken; ReadEventArgs.SetBuffer(token.BufferOffset, token.BufferBlockSize); // Begin Receiving if (!Connection.ReceiveAsync(ReadEventArgs)) { ProcessReceive(); } } } catch (ObjectDisposedException e) { if (!DisconnectEventCalled) { // Uh-Oh. idk how we got here L.LogError("WARNING: [GamespyStream.BeginReceive] ObjectDisposedException was thrown: " + e.Message); // Disconnect user DisconnectEventCalled = true; if (OnDisconnect != null) { OnDisconnect(); } } } catch (SocketException e) { HandleSocketError(e.SocketErrorCode); } }