Coder Social home page Coder Social logo

Comments (6)

adamradocz avatar adamradocz commented on June 28, 2024 1

Yes, I tried that one as well. The problem with that is, when I tested the ConnectionContext.Abort(); the server didn't receive the IsCompleted nor the IsCancelled result. You can check it for yourself, if you add logging at the start and at the end of the OnConnectedAsync() method.

Though when I explicitly called the await connection.DisposeAsync();, the server received the IsCompleted result.

I created a PR for that: #130

from bedrockframework.

KieranDevvs avatar KieranDevvs commented on June 28, 2024

Im currently using ConnectionContext.Abort();

from bedrockframework.

KieranDevvs avatar KieranDevvs commented on June 28, 2024

Shouldnt BaseConnectionContext also have a way of getting the connection state i.e if its closed, disconnected or connected?
Im currently using the cancellation token to see if the context should still be read from but it feels wrong.
I know you can use the features to get the socket state if the connection is a socket etc but surely the connection state of a "ConnectionContext" should be known independent of a transport?

public virtual CancellationToken ConnectionClosed

while (!connectionContext.ConnectionClosed.IsCancellationRequested)
{
    await connectionSession.Reader.ReadAsync(_protocol);
    var packet = result.Message;

    //.... Handle packet ....
}

from bedrockframework.

davidfowl avatar davidfowl commented on June 28, 2024

Abort is the way to disconnect the transport for sure.

from bedrockframework.

adamradocz avatar adamradocz commented on June 28, 2024

@davidfowl In #130 PR. In the samples/ClientApplication/Program.cs at line 366, if I replace the await connection.DisposeAsync(); for connection.Abort(); nothing happens. The server won't receive IsCompleted nor IsCancelled result.

from bedrockframework.

davidfowl avatar davidfowl commented on June 28, 2024

Calling DisposeAsync to abort is incorrect. Calling Abort should work, if it doesn't work then there's a bug. DisposeAsync is implicitly called by the pipeline when the code unwinds.

from bedrockframework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.