Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8212773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:52:51+00:00 2026-06-07T10:52:51+00:00

How I pause a Server Sent Event connection? Is it even possible, or do

  • 0

How I pause a Server Sent Event connection? Is it even possible, or do I have to close the SSE and then reopen it and assign all of the event handlers again?

For example I would like to do (this is all theoretical, I do not know the pause/restart function names):

var source = new EventSource(url);

source.addEventListener("something", somefunction, false);
source.addEventListener("somethingElse", somefunction2, false);

//...some code

source.pause();


//...some code

source.restart();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:52:52+00:00Added an answer on June 7, 2026 at 10:52 am

    Yes, that’s what technically needs to happen but you can abstract it away. Note: This one only connects after you do .connect()

    function EventSource2(url) {
        this.url = url;
        this.es = null;
        this.listeners = {};
    }
    
    EventSource2.prototype = {
        constructor: EventSource2,
        
        
        connect: function() {
            this.es = new EventSource(this.url);
            this.bindEvents();
        },
        
        disconnect: function() {
            this.es.close();
            this.es = null;
        },
        
        bindEvents: function() {
            for ( var type in this.listeners ) {
                var evs = this.listeners[type];
                for( var i = 0; i < evs.length; ++i ) {
                    this.es.addEventListener( type, evs[i], false );
                }
            }
        },
        
        addEventListener: function( type, fn ) {
            if( !this.listeners[type] ) {
                this.listeners[type] = [];
            }
            
            this.listeners[type].push( fn );
            if( this.es ) {
                this.bindEvents();
            }
        }
    }
    

    Usage:

    var source = new EventSource2(url);
    
    source.addEventListener("something", somefunction, false);
    source.addEventListener("somethingElse", somefunction2, false);
    
    source.connect();
    
    source.disconnect();
    
    source.connect();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have successfully sent email to a remote server using port their port 25
I'm trying to catch event when comment is sent. What am I doing wrong?
Problem: Flex/Flash4 client (built with FlashBuilder4) displays the xml sent from the server exactly
From what I have been able to understand, hash marks (#) aren't sent to
I'm writing a program that will have both a server side and a client
i have data that i fetch from an email server i want to eliminate
I'm requesting information from a remote server which is sent back to me as
I have two separate apps - one a client (in C#), one a server
I have a web server that runs off of Indy's TIdTCPServer component. I have
I have a table of paged data, along with a dynamically created pager (server-side

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.