private async Task Init() { var cameraStatus = await Permissions.RequestAsync <Permissions.Camera>(); var micStatus = await Permissions.RequestAsync <Permissions.Microphone>(); _webRtcClient = new WebRtcClient(this, _remoteView, _localView, this); var dialogTcs = new TaskCompletionSource <string>(); var linearLayout = new LinearLayout(this); linearLayout.Orientation = Orientation.Vertical; linearLayout.SetPadding(48, 24, 48, 24); var ipAddr = new EditText(this) { Hint = "IP Address", Text = "192.168.1.119" }; var port = new EditText(this) { Hint = "Port", Text = "8080" }; linearLayout.AddView(ipAddr); linearLayout.AddView(port); var alert = new AlertDialog.Builder(this) .SetTitle("Socket Address") .SetView(linearLayout) .SetPositiveButton("OK", (sender, args) => { dialogTcs.TrySetResult($"ws://{ipAddr.Text}:{port.Text}"); }) .Create(); alert.Show(); var wsUrl = await dialogTcs.Task; var okHttpClient = new OkHttpClient.Builder() .ReadTimeout(0, Java.Util.Concurrent.TimeUnit.Milliseconds) .Build(); var request = new Request.Builder() .Url(wsUrl) .Build(); _socket = okHttpClient.NewWebSocket( request, new WebSocketObserver(ReadMessage)); }
public ViewController() { View.BackgroundColor = ColorHelper.SystemBackgroundColor; _webRtcClient = new WebRtcClient(this); }