thibauts / node-castv2

An implementation of the Chromecast CASTV2 protocol
MIT License
769 stars 100 forks source link

How to connect and send requests to an application ? #3

Closed rowntreerob closed 10 years ago

rowntreerob commented 10 years ago

my app loads ok but the socket observer in the client never gets called on response messages. The connect should result in a response msg contains the SESSION.. But nothing called on receipt of a packet.

stdout

* WARNING * The program 'nodejs' uses the Apple Bonjour compatibility layer of Avahi. * WARNING * Please fix your application to use the native API of Avahi! * WARNING * For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs * WARNING * The program 'nodejs' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi. * WARNING * Please fix your application to use the native API of Avahi! * WARNING * For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs&f=DNSServiceRegister found device borneoTV at 192.168.1.141:8009 castv2-messagebus connecting to 192.168.1.141:8009 ... +0ms castv2-messagebus connected +252ms castv2-messagebus send message: protocolVersion=0 sourceId=sender-0 destinationId=receiver-0 namespace=urn:x-cast:com.google.cast.tp.connection data={"type":"CONNECT"} +0ms castv2-messagebus send message: protocolVersion=0 sourceId=sender-0 destinationId=receiver-0 namespace=urn:x-cast:com.google.cast.receiver data={"type":"LAUNCH","appId":"33E59692","requestId":1} +1ms castv2-messagebus send message: protocolVersion=0 sourceId=sender-0 destinationId=receiver-0 namespace=urn:x-cast:com.google.cast.receiver data={"requestId":2,"type":"LOAD","autoplay":true,"media":{"contentId":"http://files.parse.com/09d82830-ec2d-40b4-bb14-944728550685/ef26d2bc-d15f-4bef-b3d4-dd30cf909190-20140526153235.mp4","streamType":"NONE","contentType":"video/mp4"}} +0ms castv2-messagebus send message: protocolVersion=0 sourceId=sender-0 destinationId=receiver-0 namespace=urn:x-cast:com.google.cast.tp.heartbeat data={"type":"PING"} +4s castv2-messagebus send message: protocolVersion=0 sourceId=sender-0 destinationId=receiver-0 namespace=urn:x-cast:com.google.cast.tp.heartbeat data={"type":"PING"} +5s castv2-messagebus send message: protocolVersion=0 sourceId=sender-0 destinationId=receiver-0 namespace=urn:x-cast:com.google.cast.tp.heartbeat data={"type":"PING"} +5s castv2-messagebus send message: protocolVersion=0 sourceId=sender-0 destinationId=receiver-0 namespace=urn:x-cast:com.google.cast.

thibauts commented 10 years ago

I just tried to run my example code with '33E59692' instead of 'YouTube' and I get a session and "test-receiver-app" displayed on my TV. Can you reproduce this simple setup and give me feedback ?

When you get this working remember to CONNECT to the transportId of your running app, and then send the LOAD request to the same transportId (instead of receiver-0).

rowntreerob commented 10 years ago

OK. Thanks . I did protocol incorrectly. On Jun 8, 2014 3:36 PM, "Thibaut Séguy" notifications@github.com wrote:

I just tried to run my example code with '33E59692' instead of 'YouTube' and I get a session and "test-receiver-app" displayed on my TV. Can you reproduce this simple setup and give me feedback ?

When you get this working remember to CONNECT to the transportId of your running app, and then send the LOAD request to the same transportId (instead of receiver-0).

— Reply to this email directly or view it on GitHub https://github.com/thibauts/node-castv2-messagebus/issues/3#issuecomment-45450686 .

thibauts commented 10 years ago

You're welcome. The code should be fairly robust and behave as expected. Though don't hesitate to come back and ask questions if you need clarifications. I will update the protocol documentation as needed.

I will also try to provide implementations of the common protocols soon, and abstractions to easily build sender apps.

rowntreerob commented 10 years ago

is it not called 'sessionId' ?

There are no response messages received by Client.onpacket(buf) when i connect.

im getting nothing back when i should be receiving a message like below on the connect...

Received: {"requestId":1,"status":{"applications":[{"appId":"00000000-0000-0000-0000-000000000000","displayName":"IMAX","sessionId":"A613B8BB-B849-5ED7-CFC6-D1ECFA4AF7E9","statusText":"Chromecast Home Screen"}],"volume":{"level":1.0,"muted":false}},"type":"RECEIVER_STATUS"}

Without the sessionId , im done.....

my logger and my Client register nothing in the Client.onPacket() function.

my log should show "recv message:" after the connect.

On Sun, Jun 8, 2014 at 3:43 PM, Robert Rowntree rowntreerob@gmail.com wrote:

OK. Thanks . I did protocol incorrectly. On Jun 8, 2014 3:36 PM, "Thibaut Séguy" notifications@github.com wrote:

I just tried to run my example code with '33E59692' instead of 'YouTube' and I get a session and "test-receiver-app" displayed on my TV. Can you reproduce this simple setup and give me feedback ?

When you get this working remember to CONNECT to the transportId of your running app, and then send the LOAD request to the same transportId (instead of receiver-0).

— Reply to this email directly or view it on GitHub https://github.com/thibauts/node-castv2-messagebus/issues/3#issuecomment-45450686 .

thibauts commented 10 years ago

CONNECT doesn't elicit any response from the platform receiver. There is never any response to this message.

Start from the mental frame that the protocol isn't request / response but message-based. Some namespaces / protocols implement request / response models on top of it. urn:x-cast:com.google.cast.tp.connection isn't one of them.

To answer your specific question, the sessionId will be of little use to you for now. What you're looking for is the transportId. As I said above you have to CONNECT to it. A sessionId identifies a running instance of an app, but the transportId is really the "name" of who you are talking to. This is kinda the "receiver-0" of apps.

The Protocol Description answers most of your questions if you look closely.

rowntreerob commented 10 years ago

Thank you. I'll read this. On Jun 8, 2014 4:24 PM, "Thibaut Séguy" notifications@github.com wrote:

CONNECT doesn't elicit any response from the platform receiver. There is never any response to this message.

Start from the mental frame that the protocol isn't request / response but message-based. Some namespaces / protocols implement request / response models on top of it. urn:x-cast:com.google.cast.tp.connection isn't one of them.

To answer your specific question, the sessionId will be of little use to you for now. What you're looking for is the transportId. As I said above you have to CONNECT to it. A sessionId identifies a running instance of an app, but the transportId is really the "name" of who you are talking to. This is kinda the "receiver-0" of apps.

The Protocol Description https://github.com/thibauts/node-castv2-messagebus#protocol-description answers most of your questions if you look closely.

— Reply to this email directly or view it on GitHub https://github.com/thibauts/node-castv2-messagebus/issues/3#issuecomment-45451739 .