GithubHelp home page GithubHelp logo

Comments (16)

isfarax avatar isfarax commented on July 28, 2024

what do you mean by this?

usually i would destroy the variable that holds the handler and then when you disconnect you also have to flush in the process too - and thats what people on the internet do anyway.

i think that way you can manage what you do with the handler in each case.

from strophejs.

akarelas avatar akarelas commented on July 28, 2024

Are we talking about the same kind of handlers here? I'm talking about the kind of handlers that you create with connection.addHandler(...)

So, how do you suggest I "destroy the variable that holds the handler"? How do I destroy a variable? Also, you say I should flush in the process. Which process are you talking about? How do I flush it?

Thanks.

from strophejs.

akarelas avatar akarelas commented on July 28, 2024

Is anyone around?

from strophejs.

isfarax avatar isfarax commented on July 28, 2024

Sorry I forgot to reply, the flush method is within the strophe connection i believe. i will have to sift through my code later and get back to you. hang tight my friend.

from strophejs.

akarelas avatar akarelas commented on July 28, 2024

Hi @isfarax , do we have any news? The flush method does something completely different, it flushes the data, so it's not what I want.

from strophejs.

isfarax avatar isfarax commented on July 28, 2024

Hi @akarelas

this is from the book:

var ref = conn.addHandler(my_handler_function, null, “message”);
// once the handler is no longer needed:
connection.deleteHandler(ref);

that is how you should add and remove references to a handler. i hope this is what you are wanting to achieve.

from strophejs.

akarelas avatar akarelas commented on July 28, 2024

This doesn't work. I tried it on my websocket-style connection. If you don't believe me, that deleteHandler does absolutely nothing, tell me and I will demonstrate it with a plunkr

from strophejs.

isfarax avatar isfarax commented on July 28, 2024

if you are wanting to manage user/connection session, you should look into RID and SID because if the connection gets disconnected then i wouldnt be surprised if the handlers get wiped out too.

from strophejs.

akarelas avatar akarelas commented on July 28, 2024

What's RID and SID?

from strophejs.

akarelas avatar akarelas commented on July 28, 2024

All I want is to not end up with 150 thousand handlers on my connection, just because the server was down for a minute and my client was trying to reconnect again and again.

from strophejs.

akarelas avatar akarelas commented on July 28, 2024

Would you like me to set up a plunkr, to demonstrate to you that deleteHandler does absolutely NOTHING?

from strophejs.

akarelas avatar akarelas commented on July 28, 2024

Will you do something about it afterwards, when I've shown it?

from strophejs.

isfarax avatar isfarax commented on July 28, 2024

SID (Session Identification) and RID (Reference Identification) are to manage user sessions, typically when a user is attempting to login in again. after you disconnected, you can use the SID and RID to login into the server, it is like taking a shortcut and it is the recommending way of doing it - this also doesnt create 150 thousand connections to your server.

from strophejs.

akarelas avatar akarelas commented on July 28, 2024

Does this mean you're not interested in my demonstrating that deleteHandler does nothing?

from strophejs.

isfarax avatar isfarax commented on July 28, 2024

i am, show me

from strophejs.

Gordin avatar Gordin commented on July 28, 2024

@akarelas

  1. This works, the deleteHandler function does not do nothing...
    var ref = conn.addHandler(my_handler_function, null, “message”);
    // once the handler is no longer needed:
    connection.deleteHandler(ref);
    If you can show us how to reproduce that it doesn't it will be fixed.
  2. The handlers are always flushed after a disconnect and during a reset. Specifically a few lines after the Strophe.Connection Status is set to DISCONNECTED. The only way handlers from a previous session could interfere with a new one would be if you would hook status DISCONNECTING or DISCONNECTED or instantly reconnect before the handlers are cleared. Depending on your hooks for DISCONNECTING or DISCONNECTED the handlers could survive a reconnect for a few seconds.

I'm not really sure why the handlers are currently cleared after DISCONNECTED is set, I'll push a patch that reverses the order here. If you still have problems reopen this.

from strophejs.

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.