Java Client Small Clean up Items(#6969)
This commit is contained in:
parent
574be0d22c
commit
aca9bffd23
|
|
@ -249,10 +249,9 @@ public class HubConnection {
|
|||
|
||||
if (negotiateResponse.getAccessToken() != null) {
|
||||
this.accessTokenProvider = Single.just(negotiateResponse.getAccessToken());
|
||||
String token = "";
|
||||
// We know the Single is non blocking in this case
|
||||
// It's fine to call blockingGet() on it.
|
||||
token = this.accessTokenProvider.blockingGet();
|
||||
String token = this.accessTokenProvider.blockingGet();
|
||||
this.headers.put("Authorization", "Bearer " + token);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class OkHttpWebSocketWrapper extends WebSocketWrapper {
|
|||
}
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(url.toString())
|
||||
.url(url)
|
||||
.headers(headerBuilder.build())
|
||||
.build();
|
||||
|
||||
|
|
|
|||
|
|
@ -1288,7 +1288,7 @@ class HubConnectionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void connectionTimesOutIfServerDoesNotSendMessage() throws InterruptedException, ExecutionException, TimeoutException {
|
||||
public void connectionTimesOutIfServerDoesNotSendMessage() {
|
||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com");
|
||||
hubConnection.setServerTimeout(1);
|
||||
hubConnection.setTickRate(1);
|
||||
|
|
@ -1373,7 +1373,7 @@ class HubConnectionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void hubConnectionCanBeStartedAfterBeingStopped() throws Exception {
|
||||
public void hubConnectionCanBeStartedAfterBeingStopped() {
|
||||
MockTransport transport = new MockTransport();
|
||||
HubConnection hubConnection = HubConnectionBuilder
|
||||
.create("http://example.com")
|
||||
|
|
|
|||
|
|
@ -15,14 +15,11 @@ public class Chat {
|
|||
Scanner reader = new Scanner(System.in); // Reading from System.in
|
||||
String input = reader.nextLine();
|
||||
|
||||
System.out.print("Enter your name:");
|
||||
String enteredName = reader.nextLine();
|
||||
|
||||
HubConnection hubConnection = HubConnectionBuilder.create(input).build();
|
||||
|
||||
hubConnection.on("Send", (name, message) -> {
|
||||
System.out.println(name + ": " + message);
|
||||
}, String.class, String.class);
|
||||
hubConnection.on("Send", (message) -> {
|
||||
System.out.println(message);
|
||||
}, String.class);
|
||||
|
||||
hubConnection.onClosed((ex) -> {
|
||||
if (ex != null) {
|
||||
|
|
@ -37,7 +34,7 @@ public class Chat {
|
|||
while (!message.equals("leave")) {
|
||||
// Scans the next token of the input as an int.
|
||||
message = reader.nextLine();
|
||||
hubConnection.send("Send", enteredName, message);
|
||||
hubConnection.send("Send", message);
|
||||
}
|
||||
|
||||
hubConnection.stop();
|
||||
|
|
|
|||
Loading…
Reference in New Issue