Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple phones to be connected at the same time #13

Open
Fusion86 opened this issue May 1, 2022 · 1 comment
Open

Allow multiple phones to be connected at the same time #13

Fusion86 opened this issue May 1, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@Fusion86
Copy link
Owner

Fusion86 commented May 1, 2022

No description provided.

@Fusion86 Fusion86 added the enhancement New feature or request label May 1, 2022
@achermam
Copy link

This is quite simple...
Modify the "Start" method of Scrcpy class:

public void Start(long timeoutMs = 5000)
{
    if (Connected)
        throw new Exception("Already connected.");
    Port = new Random().Next(20000, 30000);
    MobileServerSetup();
    listener = new TcpListener(IPAddress.Loopback, Port);
    listener.Start();
// ~~ snip ~~

where port is eigther a property or a field.
public int Port { get; private set; }

Then Update "MobileServerSetup" as follows:

private void MobileServerSetup()
{
    MobileServerCleanup();

    // Push scrcpy-server.jar
    UploadMobileServer();

    // Create port reverse rule
   adb.CreateReverseForward(device, "localabstract:scrcpy", $"tcp:{Port}", true);
}

You could also ask your OS for some free port number...

HTH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants