Skip to content

MessageChannel

UnknownSKL edited this page Jul 30, 2021 · 6 revisions

The message channel uses JSON as data format to communicate. The channel can send and receive messages in both directions

Messages

All messages are JSON strings converted to a ByteBuffer. In Javascript this can be done using:

data = (new TextEncoder).encode(data)

Handshake Request:

{
    "type":"Handshake",
    "version":"messageV1",
    "id":"0ab125e2-6eee-4687-a2f4-5cfb347f0643",
    "cv":""
}

Handshake Response:

{
    "type":"HandshakeAck",
    "version":"messageV1",
    "id":"0ab125e2-6eee-4687-a2f4-5cfb347f0643",
    "cv":""
}

Game title change

The Xbox will send a message once a game changes.

{
    content: "{\"titleaumid\":\"PlayfulCorp.49013BFBD8849_7n7np5b8s1z70!NewSuperLuckysTale\",\"titleid\":\"71485103\"}"
    cv: ""
    id: "{166abad3-0542-4bf7-ae65-bb23e1d2f026}"
    target: "/streaming/properties/titleinfo"
    type: "Message"
}

Custom UI Setup

The message channel allows the stream to have custom UI control for Xbox dialogs.

Setup Custom UI Request

{
    "type": "Message",
    "content": {
        "version": [0,1,0],
        "systemUis":[10,19,31,27,32]
    },
    "id": "41f93d5a-900f-4d33-b7a1-2d4ca6747072",
    "target": "/streaming/systemUi/configuration",
    "cv": ""
}

Dialog Message

When a modal request comes op on the Xbox, you will receive a message via the message channel. A sample message can be seen below:

{
    content: "{\"TitleText\":\"Disconnect from stream?\",\"ContentText\":\"\",\"Options\":0,\"CommandLabel1\":\"Disconnect\",\"CommandLabel2\":\"Keep playing\",\"CommandLabel3\":\"\",\"DefaultIndex\":1,\"CancelIndex\":1}"
    cv: ""
    id: "{66ea6856-c2f7-474e-a6d1-9578f2f28cd9}"
    target: "/streaming/systemUi/messages/ShowMessageDialog"
    type: "TransactionStart"
}

content field contains a JSON encoded string like below:

{
    CancelIndex: 1
    CommandLabel1: "Disconnect"
    CommandLabel2: "Keep playing"
    CommandLabel3: ""
    ContentText: ""
    DefaultIndex: 1
    Options: 0
    TitleText: "Disconnect from stream?"
}

There will be no dialog on the video output when the custom UI is active. You need to respond on the channel using the packet below:

{
    "type": "TransactionComplete",
    "content":"{\"Result\":0}",
    "id": "{66ea6856-c2f7-474e-a6d1-9578f2f28cd9}",
    "cv": ""
}

Content sends back a JSON encoded string back with the following format: { "Result": labelIndex }