Home Help Center

Ice for JavaScript compiling Murmur.ice errors.

Darkman802Darkman802 Member Caleb PineurOrganization: MumblisProject: Mumble Ice Interface
I'm attempting to test Ice for JavaScript with Murmur server (mumble). I compiled Murmur.ice with the given slice2js compiler to get Murmur.js, but when used it gives an error:
/home/darkman/IceJS-0.1.0-demos/demojs/Ice/minimal/Murmur.js:771
        "delete": [_delete, , , 1, , , , ,
                   ^
ReferenceError: _delete is not defined
    at /home/darkman/IceJS-0.1.0-demos/demojs/Ice/minimal/Murmur.js:771:20
    at Object.<anonymous> (/home/darkman/IceJS-0.1.0-demos/demojs/Ice/minimal/Murmur.js:1112:1)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at /home/darkman/IceJS-0.1.0-demos/demojs/Ice/minimal/ourclient.js:13:1
    at Object.<anonymous> (/home/darkman/IceJS-0.1.0-demos/demojs/Ice/minimal/ourclient.js:64:2)


If I remove '_delete' from Murmur.js, the node script runs but instead of ourclient.js getting the mumble server uptime it returns something that looks like this (truncated for space):
{ _reference:
   { _instance:
      { _state: 0,
        _initData: [Object],
        _traceLevels: {},
        _defaultsAndOverrides: [Object],
        _messageSizeMax: 1048576,
        _clientACM: 60,
        _serverACM: 0,
        _implicitContext: null,
        _routerManager: [Object],
        _locatorManager: [Object],
        _referenceFactory: [Object],
        _proxyFactory: [Object],
        _outgoingConnectionFactory: [Object],

I've attached the files for Murmur.ice, Murmur.js, and ourclient.js

EDIT: I just now saw the post for 'Patch #1 for IceJS-0.1.0: nested modules', would that fix this issue?

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Thanks for the bug report. As a quick workaround for now, you can modify the generated file and add quotes around "_delete" line 771. Not however that this workaround might not be sufficient, the call to the delete operation might still fail at the runtime. We'll look into fixing this for the next release.

    Cheers,
    Benoit.
  • Darkman802Darkman802 Member Caleb PineurOrganization: MumblisProject: Mumble Ice Interface
    Thanks for your response.

    It seems that workaround is indeed not sufficient, as trying to call the getUptime method results in the attached output.txt
  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    I assume you are doing something like
    console.log(proxy.getUptime());
    

    The above code will just log the Promise object return by the asynchronous call, the the correct way to write this will be:
    proxy.getUptime().then(
        function(t)
        {
            console.log(t);
        },
        function(ex)
        {
            console.log(ex);
        });
    

    If that is not the problem can you show us your code
  • Darkman802Darkman802 Member Caleb PineurOrganization: MumblisProject: Mumble Ice Interface
    Thank you xdm, that was the issue. I had forgotten that node was asynchronous by nature as I'm used to python. I was able to get it working with this code, is this the correct way of doing things?
    (function(){
    
    require("Ice");
    require("./Murmur.js");
    
    var communicator;
    
    Ice.Promise.try(
        function()
        {
            communicator = Ice.initialize();
    
            var proxy = communicator.stringToProxy("Meta:tcp -h localhost -p 6502");
    
            var meta = Murmur.MetaPrx.checkedCast(proxy);
    
            return meta.then(
                    function(meta) {
                            meta.getUptime().then(
                                    function(t) {
                                            console.log('uptime: %s', t);
                                    },
                                    function(ex) {
                                            console.log(ex);
                                    }
                            );
    
                            meta.getVersion().then(
                                    function(maj, min, patch, text) {
                                            console.log(maj, min, patch, text);
                                    },
                                    function(ex) {
                                            console.log(ex);
                                    }
                            );
                    },
                    function(ex) {
                            console.log(ex);
                    }
            );
        }
    ).finally(
        function()
        {
            if(communicator)
            {
                return communicator.destroy();
            }
        }
    ).exception(
        function(ex)
        {
            console.log(ex.toString());
            process.exit(1);
        });
    }());
    
    
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    Yes, your code looks fine. There are many ways to write this code in JavaScript. Below is a slightly more concise version where the exception handling is only done at one location.
    (function(){
    
    require("Ice");
    require("./Murmur.js");
    
    var communicator;
    
    Ice.Promise.try(
        function() {
            communicator = Ice.initialize();
            var proxy = communicator.stringToProxy("Meta:tcp -h localhost -p 6502");
            return Murmur.MetaPrx.checkedCast(proxy);
        }
    ).then(
        function(meta) {
            //
            // Call getUptime and getVersion concurrently and continue once both requests are completed
            //
            return Ice.Promise.all(
                meta.getUptime().then(
                     function(t) {
                         console.log('uptime: %s', t);
                     }),
                meta.getVersion().then(
                     function(maj, min, patch, text) {
                        console.log(maj, min, patch, text);
                     })
            );
        }
    ).finally(
        function() {
            if(communicator) {
                return communicator.destroy();
            }
        }
    ).exception(
        function(ex) {
            console.log(ex.toString());
            process.exit(1);
        });
    }());
    
Sign In or Register to comment.