thibauts / node-castv2-client

A Chromecast client based on the new (CASTV2) protocol
MIT License
649 stars 95 forks source link

Error: Illegal wire type for field Message.Field #28

Closed fean closed 9 years ago

fean commented 9 years ago

I'm trying to control our Styled Media Receiver with your CASTV2 module for NodeJS. It has been very easy to implement so far. But right after I launch the receiver application the following error occurs:

Error: Illegal wire type for field Message.Field .extensions.api.cast_channel.CastMessage.payload_type: 5 (0 expected)
    at Error (<anonymous>)
    at ProtoBuf.Reflect.FieldPrototype.decode (/private/var/folders/jp/k4c47sy57b3chb9fv4wfg9xh0000gn/T/.org.chromium.Chromium.Zvgrtn/node_modules/castv2-client/node_modules/castv2/node_modules/protobufjs/dist/ProtoBuf.js:3043:27)
    at ProtoBuf.Reflect.MessagePrototype.decode (/private/var/folders/jp/k4c47sy57b3chb9fv4wfg9xh0000gn/T/.org.chromium.Chromium.Zvgrtn/node_modules/castv2-client/node_modules/castv2/node_modules/protobufjs/dist/ProtoBuf.js:2462:49)
    at Function.Message.decode (/private/var/folders/jp/k4c47sy57b3chb9fv4wfg9xh0000gn/T/.org.chromium.Chromium.Zvgrtn/node_modules/castv2-client/node_modules/castv2/node_modules/protobufjs/dist/ProtoBuf.js:2190:41)
    at Object.module.exports.(anonymous function).parse (/private/var/folders/jp/k4c47sy57b3chb9fv4wfg9xh0000gn/T/.org.chromium.Chromium.Zvgrtn/node_modules/castv2-client/node_modules/castv2/lib/proto.js:22:34)
    at PacketStreamWrapper.onpacket (/private/var/folders/jp/k4c47sy57b3chb9fv4wfg9xh0000gn/T/.org.chromium.Chromium.Zvgrtn/node_modules/castv2-client/node_modules/castv2/lib/client.js:61:31)
    at PacketStreamWrapper.EventEmitter.emit (events.js:95:17)
    at CleartextStream.eval (/private/var/folders/jp/k4c47sy57b3chb9fv4wfg9xh0000gn/T/.org.chromium.Chromium.Zvgrtn/node_modules/castv2-client/node_modules/castv2/lib/packet-stream-wrapper.js:28:16)
    at CleartextStream.EventEmitter.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:408:10)

After that error message it goes on about some other errors about groupings. This is the code I used:

var Chromecast = require('castv2-client').Client;

function connectChromecast(name, service) {
    var client = new Chromecast();

    client.connect(service.addresses[0], function() {
        console.log('Connected to ' + name);
        client.launch({
            APP_ID: '[Our App ID]'
        }, function(err, app) {
            console.log(name + ' is ready to cast.');   
        });
    });
}
thibauts commented 9 years ago

The first parameter of launch is a sublcass of Application. For a styled media receiver it would be a subclass of DefaultMediaReceiver with another APP_ID.

Or follow the example and do something like that before launch :

DefaultMediaReceiver.APP_ID = '[YOUR APP_ID]';

But i'd suggest subclassing DMR, it would be much cleaner :)

fean commented 9 years ago

Thanks for responding this quickly. Well that actually makes sense ;)

I'm going to test it right now. If that lifts the problem I'l close the issue right away!