ws-scrcpy icon indicating copy to clipboard operation
ws-scrcpy copied to clipboard

[Feature Request] Can we get device list from API instead of websocket?

Open mhaqqiw opened this issue 3 years ago • 5 comments

mhaqqiw avatar Oct 21 '21 02:10 mhaqqiw

Hi. What for? The main reason for receiving device list via WebSocket is that the list is automatically updated by the server then you connect/remove devices.

drauggres avatar Oct 21 '21 10:10 drauggres

it will make easier to integrate to another app / service.

mhaqqiw avatar Oct 25 '21 02:10 mhaqqiw

@drauggres hi, i found that this issue #89 and pr #91 should fixed this issue. however, i am getting error: can not get xxx for "http://127.0.0.1:8000/droid-device-list". and websocket error: Unsupported request for "ws://127.0.0.1:8000/?action=goog-device-list". did i miss anything here?

my ws-scrcpy version is: "version": "0.8.0-dev"

eaphone avatar Feb 18 '22 16:02 eaphone

Hi @eaphone As you can guess by the -dev suffix this version is under development (sadly not really very active). This request doesn't work anymore. I've changed the API: now all websocket-request to the server use the same single connection instead of a separate one.

There is no simple way to switch it back without changing the code. If you ready to do this, you will need to add this method to src/app/googDevice/client/DeviceTracker.ts:

    protected supportMultiplexing(): boolean {
        return false;
    }

and change this in src/server/index.ts:

    if (config.getRunLocalGoogTracker()) {
        mwList.push(DeviceTracker); // was mw2List
    }

After that this request should work: ws://HOST:8000/?action=goog-device-list. I don't remember http://127.0.0.1:8000/droid-device-list ever working. But since now this project uses express it should be easy to add this route, see src/server/services/HttpServer.ts

drauggres avatar Feb 18 '22 17:02 drauggres

@drauggres hi, thx for your reply.

changing the code did work prefectly!

eaphone avatar Feb 19 '22 18:02 eaphone