You should only create the client.notify
method once, not each time the change event on the scheduler widget is triggered. Same goes for starting the connection.
So it should probably be something like:
// set up hub methods and start connection ..
var notificationHub = $.connection.MyBookingHub;
notificationHub.client.Notify = function (MyStart, MyEnd, MyMessage) {
var scheduler = $("#scheduler").data("kendoScheduler");
scheduler.dataSource.add({
start: new Date(MyStart),
end: new Date(MyEnd),
title: "Costas Interview"
});
};
window.hubConnection = $.connection.hub.start();
// create scheduler change handler
function scheduler_change(e) {
var start = e.start; //selection start date
var end = e.end; //selection end date
var slots = e.slots; //list of selected slots
var events = e.events; //list of selected Scheduler events
window.hubConnection.done(function () {
notificationHub.server.sendNotification(start, end, "Booking Title");
});
}