Error updating several clients with Socket.io

0

I have a calendar (fullCalendar.io), after creating / updating an event, I save in the BD and refresh the calendar:

function refreshEvent()
{
  $('#calendar').fullCalendar('refetchEvents');
};

I have no problems with this.

I implemented socket.io, and doing tests, from Browser1 when I refresh the calendar using the previous function, it is updated in Browser2 but in Browser1 it generates an error " there was an error while fetching events! "

The creation of the calendar is like this:

$('#calendar').fullCalendar({
      windowResize: function(view) {},
      header: {
        left: 'prev,next today',
        center: 'title',
        right: 'agendaWeek'
      },
      allDaySlot: false,scrollTime: '07:00:00',defaultView: 'agendaWeek',
      weekNumbers: true,navLinks: true,editable: true,eventLimit: true,
      droppable: true,
      eventDrop: function(event, delta, revertFunc) {
        var obj = {}
        obj.cAccion = 'M'
        obj.nId = event.id
        obj.cTitle = event.title;
        obj.cStart = assembleFullDate(event.start._i,'start');
        obj.cEnd = assembleFullDate(event.start._i,'end');
        obj.cClassName = selectClass(event.title);
        obj.idEvent = 0;
        var rF = cudObj("/cudEvents",obj);
      },
      eventReceive: function(event) {
        var obj = {}
        obj.cAccion = 'C'
        obj.nId = 0
        obj.cTitle = event.title;
        obj.cStart = assembleFullDate(event.start._i,'start');
        obj.cEnd = assembleFullDate(event.start._i,'end');
        obj.cClassName = selectClass(event.title);
        obj.idEvent = event.id;
        var rF = cudObj("/cudEvents",obj);
      },
      eventSources: [
        {
          url: '/dataSimulation',
          type: 'GET',
          error: function() {
            alert('there was an error while fetching events!');
          }
        }
      ],
      businessHours: {
        dow: [ 1, 2, 3, 4, 5 ],
        start: '07:00',
        end: '18:00',
      },
    });

On socket.js

function calendarChange()
{
    socket.emit('calendarChange');  
}
socket.on('newDates', function(){
    console.log("newDates");
    refreshEvent()
});

at www

socket.on('calendarChange', function(){
    console.log('calendarChange'.green);
    io.emit('newDates');
  });
    
asked by ValVert 09.08.2018 в 22:06
source

1 answer

0

Finally the error was not in fullCalendar but in the way I implemented the connection to the database (hence the problem is another). In StackOverflow_EN they asked me about the result of :

error: function(err) {
    console.log(err)
}

the result was: " Global connection already exists. Call sql.close () first "

    
answered by 10.08.2018 / 04:03
source