0

我目前面临的问题与场景内容的加载和重新加载有关。今天运行的应用程序对网络断开和重新连接的响应不佳。

例如,有些州的 ajax-state 为 200 / 罚款 .. 但传入的数据为 NULL -> 导致空场景。

这是我的控制器现在看起来的片段:

Controller.assignEvents = function() {
    var player = document.getElementById('pluginObjectPlayer');
    player.OnConnectionFailed = 'Controller.ConnectionFailed';
    player.OnNetworkDisconnected = 'Controller.NetworkDisconnected';
    player.OnStreamNotFound = 'Controller.StreamNotFound';

    $$(document).ajaxError(function(e, xhr, settings, exception) {
       alert('error (' + xhr.status + ') ' + 'in: ' + settings.url + ' | error: ' + exception);
       if(xhr.status === 0 || xhr.status === 408 || xhr.status === 504) Controller.NetworkDisconnected();
    });

    $$(document).ajaxSuccess(function(event, xhr, settings){
        alert('ajaxSuccess('+xhr.status+'): ' + settings.url);
        if(settings.url.indexOf('http:') === 0) {
            if(Controller.no_network) {
                Controller.no_network = false;
                Controller.hideNotification();
            }
        }
    });
}

Controller.ConnectionFailed = function() {
    alert("Stream connection failed");
    Controller.no_network = true;
    Controller.showNotification('Nema mreze');
}

Controller.NetworkDisconnected = function() {
    alert('NetworkDisconnected');

    Controller.no_network = true;
    Controller.showNotification('Nema mreze');


    if(typeof sf.scene.get('Youtube') != 'undefined' && sf.scene.get('Youtube').isVideoPlaying){
        sf.scene.hide('Overlay');
    } else {

        sf.scene.get('Content').streamStop(false);
    }

    sf.scene.get('Content').streamStop(false);
}

Controller.NetworkResumed = function() {
    alert('NetworkResumed');

    Controller.no_network = false;

    Controller.hideNotification();

    if(Controller.starting){
        Controller.startup();
    } else {
        alert("Start timeout on resume");
        $('#buffering').show();
        setTimeout(function(){
            sf.scene.get('Content').streamResume(false);
            $('#buffering').hide();
        }, 5000);
    }
}

Controller.isConnectionAvailable = function() {

    if(sf.core.getEnvValue("modelid") == 'SDK') return Controller.SDK_NETWORK;

    var network = document.getElementById('pluginObjectNetwork');

    var interfaceType = network.GetActiveType();

    if(interfaceType === -1) return false;

    var physicalConn = network.CheckPhysicalConnection(interfaceType);

    if(physicalConn !== 1) return false;

    var httpStatus = network.CheckHTTP(interfaceType);

    if(physicalConn !== 1) return false;

    return true;
}

Controller.pollNetwork = function() {
    alert('polling network');

    var prevStatus = Controller.no_network;
    Controller.no_network = !Controller.isConnectionAvailable();

    if(! Controller.no_network && prevStatus) {
        Controller.NetworkResumed();
    }
    else if(Controller.no_network && ! prevStatus) {
        Controller.NetworkDisconnected();
    }

    setTimeout(Controller.pollNetwork, 2000);
}

有谁知道如何解决这个问题?谢谢 !

4

1 回答 1

0

我建议您在确定它成功之前也检查一下 xhr.responseText 。有时它发生在 200 代码状态但响应正文为空

于 2013-08-01T03:16:22.423 回答