Skip to content

Update BridgeController.java #14

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ public BridgeController() {
public void Open(final String wsuri, final String protocol) {
Log("BridgeController:Open");

AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setTrustManagers(new TrustManager[] {
int port = 80;
// Get the port number via the 2nd ":".
String uristring = wsuri.substring(wsuri.indexOf(":")+1);
if (uristring.indexOf(":") > 0)
{
port = Integer.parseInt(uristring.substring(uristring.indexOf(":")+1));
}

AsyncHttpClient(port).getDefaultInstance().getSSLSocketMiddleware().setTrustManagers(new TrustManager[] {
new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain, String authType) {}
public void checkServerTrusted(X509Certificate[] chain, String authType) {}
Expand All @@ -56,13 +64,12 @@ public void checkServerTrusted(X509Certificate[] chain, String authType) {}
sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, null, null);

AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setSSLContext(sslContext);
AsyncHttpClient(port).getDefaultInstance().getSSLSocketMiddleware().setSSLContext(sslContext);
} catch (Exception e){
Log.d("SSLCONFIG", e.toString(), e);
}


AsyncHttpClient.getDefaultInstance().websocket(wsuri, protocol, new AsyncHttpClient
AsyncHttpClient(port).getDefaultInstance().websocket(wsuri, protocol, new AsyncHttpClient
.WebSocketConnectCallback()
{
@Override
Expand Down
6 changes: 4 additions & 2 deletions Websockets.Universal/WebsocketConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public void Open(string url, string protocol = null)
else if (url.StartsWith("http"))
url = url.Replace("http://", "ws://");

_websocket.ConnectAsync(new Uri(url)).Completed = (source, status) =>
Uri uri = new Uri(url);
int port = uri.Port.ToString();
_websocket.ConnectAsync(uri, port).Completed = (source, status) =>
{
if (status == AsyncStatus.Completed)
{
Expand Down Expand Up @@ -132,4 +134,4 @@ void _websocket_Closed(IWebSocket sender, WebSocketClosedEventArgs args)
OnClosed();
}
}
}
}