[Java] Cleanup exceptions (#3110)
This commit is contained in:
parent
286e4bebf7
commit
9049bf709c
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
package com.microsoft.signalr;
|
package com.microsoft.signalr;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
@ -197,12 +196,7 @@ public class HubConnection {
|
||||||
if (response.getStatusCode() != 200) {
|
if (response.getStatusCode() != 200) {
|
||||||
throw new RuntimeException(String.format("Unexpected status code returned from negotiate: %d %s.", response.getStatusCode(), response.getStatusText()));
|
throw new RuntimeException(String.format("Unexpected status code returned from negotiate: %d %s.", response.getStatusCode(), response.getStatusText()));
|
||||||
}
|
}
|
||||||
NegotiateResponse negotiateResponse;
|
NegotiateResponse negotiateResponse = new NegotiateResponse(response.getContent());
|
||||||
try {
|
|
||||||
negotiateResponse = new NegotiateResponse(response.getContent());
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (negotiateResponse.getError() != null) {
|
if (negotiateResponse.getError() != null) {
|
||||||
throw new RuntimeException(negotiateResponse.getError());
|
throw new RuntimeException(negotiateResponse.getError());
|
||||||
|
|
@ -409,18 +403,18 @@ public class HubConnection {
|
||||||
*
|
*
|
||||||
* @param method The name of the server method to invoke.
|
* @param method The name of the server method to invoke.
|
||||||
* @param args The arguments to be passed to the method.
|
* @param args The arguments to be passed to the method.
|
||||||
* @throws Exception If there was an error while sending.
|
|
||||||
*/
|
*/
|
||||||
public void send(String method, Object... args) throws Exception {
|
public void send(String method, Object... args) {
|
||||||
if (hubConnectionState != HubConnectionState.CONNECTED) {
|
if (hubConnectionState != HubConnectionState.CONNECTED) {
|
||||||
throw new HubException("The 'send' method cannot be called if the connection is not active");
|
throw new RuntimeException("The 'send' method cannot be called if the connection is not active");
|
||||||
}
|
}
|
||||||
|
|
||||||
InvocationMessage invocationMessage = new InvocationMessage(null, method, args);
|
InvocationMessage invocationMessage = new InvocationMessage(null, method, args);
|
||||||
sendHubMessage(invocationMessage);
|
sendHubMessage(invocationMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> Single<T> invoke(Class<T> returnType, String method, Object... args) throws Exception {
|
@SuppressWarnings("unchecked")
|
||||||
|
public <T> Single<T> invoke(Class<T> returnType, String method, Object... args) {
|
||||||
String id = connectionState.getNextInvocationId();
|
String id = connectionState.getNextInvocationId();
|
||||||
InvocationMessage invocationMessage = new InvocationMessage(id, method, args);
|
InvocationMessage invocationMessage = new InvocationMessage(id, method, args);
|
||||||
|
|
||||||
|
|
@ -451,7 +445,7 @@ public class HubConnection {
|
||||||
return Single.fromFuture(future);
|
return Single.fromFuture(future);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendHubMessage(HubMessage message) throws Exception {
|
private void sendHubMessage(HubMessage message) {
|
||||||
String serializedMessage = protocol.writeMessage(message);
|
String serializedMessage = protocol.writeMessage(message);
|
||||||
if (message.getMessageType() == HubMessageType.INVOCATION) {
|
if (message.getMessageType() == HubMessageType.INVOCATION) {
|
||||||
logger.log(LogLevel.Debug, "Sending %s message '%s'.", message.getMessageType().name(), ((InvocationMessage)message).getInvocationId());
|
logger.log(LogLevel.Debug, "Sending %s message '%s'.", message.getMessageType().name(), ((InvocationMessage)message).getInvocationId());
|
||||||
|
|
@ -777,7 +771,7 @@ public class HubConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Class<?>> getParameterTypes(String methodName) throws Exception {
|
public List<Class<?>> getParameterTypes(String methodName) {
|
||||||
List<InvocationHandler> handlers = connection.handlers.get(methodName);
|
List<InvocationHandler> handlers = connection.handlers.get(methodName);
|
||||||
if (handlers == null) {
|
if (handlers == null) {
|
||||||
logger.log(LogLevel.Warning, "Failed to find handler for '%s' method.", methodName);
|
logger.log(LogLevel.Warning, "Failed to find handler for '%s' method.", methodName);
|
||||||
|
|
@ -785,7 +779,7 @@ public class HubConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handlers.isEmpty()) {
|
if (handlers.isEmpty()) {
|
||||||
throw new Exception(String.format("There are no callbacks registered for the method '%s'.", methodName));
|
throw new RuntimeException(String.format("There are no callbacks registered for the method '%s'.", methodName));
|
||||||
}
|
}
|
||||||
|
|
||||||
return handlers.get(0).getClasses();
|
return handlers.get(0).getClasses();
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
package com.microsoft.signalr;
|
package com.microsoft.signalr;
|
||||||
|
|
||||||
public class HubException extends Exception {
|
public class HubException extends RuntimeException {
|
||||||
private static final long serialVersionUID = -572019264269821519L;
|
private static final long serialVersionUID = -572019264269821519L;
|
||||||
|
|
||||||
public HubException() {
|
public HubException() {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ interface HubProtocol {
|
||||||
* @param message A string representation of one or more {@link HubMessage}s.
|
* @param message A string representation of one or more {@link HubMessage}s.
|
||||||
* @return A list of {@link HubMessage}s.
|
* @return A list of {@link HubMessage}s.
|
||||||
*/
|
*/
|
||||||
HubMessage[] parseMessages(String message, InvocationBinder binder) throws Exception;
|
HubMessage[] parseMessages(String message, InvocationBinder binder);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes the specified {@link HubMessage} to a String.
|
* Writes the specified {@link HubMessage} to a String.
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,5 @@ import java.util.List;
|
||||||
|
|
||||||
interface InvocationBinder {
|
interface InvocationBinder {
|
||||||
Class<?> getReturnType(String invocationId);
|
Class<?> getReturnType(String invocationId);
|
||||||
List<Class<?>> getParameterTypes(String methodName) throws Exception;
|
List<Class<?>> getParameterTypes(String methodName);
|
||||||
}
|
}
|
||||||
|
|
@ -36,105 +36,109 @@ class JsonHubProtocol implements HubProtocol {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HubMessage[] parseMessages(String payload, InvocationBinder binder) throws Exception {
|
public HubMessage[] parseMessages(String payload, InvocationBinder binder) {
|
||||||
if (payload != null && !payload.substring(payload.length() - 1).equals(RECORD_SEPARATOR)) {
|
if (payload != null && !payload.substring(payload.length() - 1).equals(RECORD_SEPARATOR)) {
|
||||||
throw new RuntimeException("Message is incomplete.");
|
throw new RuntimeException("Message is incomplete.");
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] messages = payload.split(RECORD_SEPARATOR);
|
String[] messages = payload.split(RECORD_SEPARATOR);
|
||||||
List<HubMessage> hubMessages = new ArrayList<>();
|
List<HubMessage> hubMessages = new ArrayList<>();
|
||||||
for (String str : messages) {
|
try {
|
||||||
HubMessageType messageType = null;
|
for (String str : messages) {
|
||||||
String invocationId = null;
|
HubMessageType messageType = null;
|
||||||
String target = null;
|
String invocationId = null;
|
||||||
String error = null;
|
String target = null;
|
||||||
ArrayList<Object> arguments = null;
|
String error = null;
|
||||||
JsonArray argumentsToken = null;
|
ArrayList<Object> arguments = null;
|
||||||
Object result = null;
|
JsonArray argumentsToken = null;
|
||||||
JsonElement resultToken = null;
|
Object result = null;
|
||||||
JsonReader reader = new JsonReader(new StringReader(str));
|
JsonElement resultToken = null;
|
||||||
reader.beginObject();
|
JsonReader reader = new JsonReader(new StringReader(str));
|
||||||
|
reader.beginObject();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
String name = reader.nextName();
|
String name = reader.nextName();
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case "type":
|
case "type":
|
||||||
messageType = HubMessageType.values()[reader.nextInt() - 1];
|
messageType = HubMessageType.values()[reader.nextInt() - 1];
|
||||||
break;
|
break;
|
||||||
case "invocationId":
|
case "invocationId":
|
||||||
invocationId = reader.nextString();
|
invocationId = reader.nextString();
|
||||||
break;
|
break;
|
||||||
case "target":
|
case "target":
|
||||||
target = reader.nextString();
|
target = reader.nextString();
|
||||||
break;
|
break;
|
||||||
case "error":
|
case "error":
|
||||||
error = reader.nextString();
|
error = reader.nextString();
|
||||||
break;
|
break;
|
||||||
case "result":
|
case "result":
|
||||||
if (invocationId == null) {
|
if (invocationId == null) {
|
||||||
resultToken = jsonParser.parse(reader);
|
resultToken = jsonParser.parse(reader);
|
||||||
} else {
|
} else {
|
||||||
result = gson.fromJson(reader, binder.getReturnType(invocationId));
|
result = gson.fromJson(reader, binder.getReturnType(invocationId));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "item":
|
case "item":
|
||||||
reader.skipValue();
|
reader.skipValue();
|
||||||
break;
|
break;
|
||||||
case "arguments":
|
case "arguments":
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
|
List<Class<?>> types = binder.getParameterTypes(target);
|
||||||
|
arguments = bindArguments(reader, types);
|
||||||
|
} else {
|
||||||
|
argumentsToken = (JsonArray)jsonParser.parse(reader);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "headers":
|
||||||
|
throw new RuntimeException("Headers not implemented yet.");
|
||||||
|
default:
|
||||||
|
// Skip unknown property, allows new clients to still work with old protocols
|
||||||
|
reader.skipValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (reader.hasNext());
|
||||||
|
|
||||||
|
reader.endObject();
|
||||||
|
reader.close();
|
||||||
|
|
||||||
|
switch (messageType) {
|
||||||
|
case INVOCATION:
|
||||||
|
if (argumentsToken != null) {
|
||||||
List<Class<?>> types = binder.getParameterTypes(target);
|
List<Class<?>> types = binder.getParameterTypes(target);
|
||||||
arguments = bindArguments(reader, types);
|
arguments = bindArguments(argumentsToken, types);
|
||||||
|
}
|
||||||
|
if (arguments == null) {
|
||||||
|
hubMessages.add(new InvocationMessage(invocationId, target, new Object[0]));
|
||||||
} else {
|
} else {
|
||||||
argumentsToken = (JsonArray)jsonParser.parse(reader);
|
hubMessages.add(new InvocationMessage(invocationId, target, arguments.toArray()));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case COMPLETION:
|
||||||
|
if (resultToken != null) {
|
||||||
|
result = gson.fromJson(resultToken, binder.getReturnType(invocationId));
|
||||||
|
}
|
||||||
|
hubMessages.add(new CompletionMessage(invocationId, result, error));
|
||||||
|
break;
|
||||||
|
case STREAM_INVOCATION:
|
||||||
|
case STREAM_ITEM:
|
||||||
|
case CANCEL_INVOCATION:
|
||||||
|
throw new UnsupportedOperationException(String.format("The message type %s is not supported yet.", messageType));
|
||||||
|
case PING:
|
||||||
|
hubMessages.add(PingMessage.getInstance());
|
||||||
|
break;
|
||||||
|
case CLOSE:
|
||||||
|
if (error != null) {
|
||||||
|
hubMessages.add(new CloseMessage(error));
|
||||||
|
} else {
|
||||||
|
hubMessages.add(new CloseMessage());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "headers":
|
|
||||||
throw new HubException("Headers not implemented yet.");
|
|
||||||
default:
|
default:
|
||||||
// Skip unknown property, allows new clients to still work with old protocols
|
|
||||||
reader.skipValue();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (reader.hasNext());
|
|
||||||
|
|
||||||
reader.endObject();
|
|
||||||
reader.close();
|
|
||||||
|
|
||||||
switch (messageType) {
|
|
||||||
case INVOCATION:
|
|
||||||
if (argumentsToken != null) {
|
|
||||||
List<Class<?>> types = binder.getParameterTypes(target);
|
|
||||||
arguments = bindArguments(argumentsToken, types);
|
|
||||||
}
|
|
||||||
if (arguments == null) {
|
|
||||||
hubMessages.add(new InvocationMessage(invocationId, target, new Object[0]));
|
|
||||||
} else {
|
|
||||||
hubMessages.add(new InvocationMessage(invocationId, target, arguments.toArray()));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case COMPLETION:
|
|
||||||
if (resultToken != null) {
|
|
||||||
result = gson.fromJson(resultToken, binder.getReturnType(invocationId));
|
|
||||||
}
|
|
||||||
hubMessages.add(new CompletionMessage(invocationId, result, error));
|
|
||||||
break;
|
|
||||||
case STREAM_INVOCATION:
|
|
||||||
case STREAM_ITEM:
|
|
||||||
case CANCEL_INVOCATION:
|
|
||||||
throw new UnsupportedOperationException(String.format("The message type %s is not supported yet.", messageType));
|
|
||||||
case PING:
|
|
||||||
hubMessages.add(PingMessage.getInstance());
|
|
||||||
break;
|
|
||||||
case CLOSE:
|
|
||||||
if (error != null) {
|
|
||||||
hubMessages.add(new CloseMessage(error));
|
|
||||||
} else {
|
|
||||||
hubMessages.add(new CloseMessage());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException("Error reading JSON.", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hubMessages.toArray(new HubMessage[hubMessages.size()]);
|
return hubMessages.toArray(new HubMessage[hubMessages.size()]);
|
||||||
|
|
|
||||||
|
|
@ -17,60 +17,64 @@ class NegotiateResponse {
|
||||||
private String accessToken;
|
private String accessToken;
|
||||||
private String error;
|
private String error;
|
||||||
|
|
||||||
public NegotiateResponse(String negotiatePayload) throws IOException {
|
public NegotiateResponse(String negotiatePayload) {
|
||||||
JsonReader reader = new JsonReader(new StringReader(negotiatePayload));
|
try {
|
||||||
reader.beginObject();
|
JsonReader reader = new JsonReader(new StringReader(negotiatePayload));
|
||||||
|
reader.beginObject();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
String name = reader.nextName();
|
String name = reader.nextName();
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case "error":
|
case "error":
|
||||||
this.error = reader.nextString();
|
this.error = reader.nextString();
|
||||||
break;
|
break;
|
||||||
case "url":
|
case "url":
|
||||||
this.redirectUrl = reader.nextString();
|
this.redirectUrl = reader.nextString();
|
||||||
break;
|
break;
|
||||||
case "accessToken":
|
case "accessToken":
|
||||||
this.accessToken = reader.nextString();
|
this.accessToken = reader.nextString();
|
||||||
break;
|
break;
|
||||||
case "availableTransports":
|
case "availableTransports":
|
||||||
reader.beginArray();
|
reader.beginArray();
|
||||||
while (reader.hasNext()) {
|
|
||||||
reader.beginObject();
|
|
||||||
while (reader.hasNext()) {
|
while (reader.hasNext()) {
|
||||||
String transport = null;
|
reader.beginObject();
|
||||||
String property = reader.nextName();
|
while (reader.hasNext()) {
|
||||||
switch (property) {
|
String transport = null;
|
||||||
case "transport":
|
String property = reader.nextName();
|
||||||
transport = reader.nextString();
|
switch (property) {
|
||||||
break;
|
case "transport":
|
||||||
case "transferFormats":
|
transport = reader.nextString();
|
||||||
// transfer formats aren't supported currently
|
break;
|
||||||
reader.skipValue();
|
case "transferFormats":
|
||||||
break;
|
// transfer formats aren't supported currently
|
||||||
default:
|
reader.skipValue();
|
||||||
// Skip unknown property, allows new clients to still work with old protocols
|
break;
|
||||||
reader.skipValue();
|
default:
|
||||||
break;
|
// Skip unknown property, allows new clients to still work with old protocols
|
||||||
|
reader.skipValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.availableTransports.add(transport);
|
||||||
}
|
}
|
||||||
this.availableTransports.add(transport);
|
reader.endObject();
|
||||||
}
|
}
|
||||||
reader.endObject();
|
reader.endArray();
|
||||||
}
|
break;
|
||||||
reader.endArray();
|
case "connectionId":
|
||||||
break;
|
this.connectionId = reader.nextString();
|
||||||
case "connectionId":
|
break;
|
||||||
this.connectionId = reader.nextString();
|
default:
|
||||||
break;
|
// Skip unknown property, allows new clients to still work with old protocols
|
||||||
default:
|
reader.skipValue();
|
||||||
// Skip unknown property, allows new clients to still work with old protocols
|
break;
|
||||||
reader.skipValue();
|
}
|
||||||
break;
|
} while (reader.hasNext());
|
||||||
}
|
|
||||||
} while (reader.hasNext());
|
|
||||||
|
|
||||||
reader.endObject();
|
reader.endObject();
|
||||||
reader.close();
|
reader.close();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException("Error reading NegotiateResponse", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getConnectionId() {
|
public String getConnectionId() {
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,5 @@
|
||||||
package com.microsoft.signalr;
|
package com.microsoft.signalr;
|
||||||
|
|
||||||
interface OnReceiveCallBack {
|
interface OnReceiveCallBack {
|
||||||
void invoke(String message) throws Exception;
|
void invoke(String message);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ interface Transport {
|
||||||
CompletableFuture<Void> start(String url);
|
CompletableFuture<Void> start(String url);
|
||||||
CompletableFuture<Void> send(String message);
|
CompletableFuture<Void> send(String message);
|
||||||
void setOnReceive(OnReceiveCallBack callback);
|
void setOnReceive(OnReceiveCallBack callback);
|
||||||
void onReceive(String message) throws Exception;
|
void onReceive(String message);
|
||||||
void setOnClose(Consumer<String> onCloseCallback);
|
void setOnClose(Consumer<String> onCloseCallback);
|
||||||
CompletableFuture<Void> stop();
|
CompletableFuture<Void> stop();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ class WebSocketTransport implements Transport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(String message) throws Exception {
|
public void onReceive(String message) {
|
||||||
this.onReceiveCallBack.invoke(message);
|
this.onReceiveCallBack.invoke(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ class HubConnectionTest {
|
||||||
private static final String RECORD_SEPARATOR = "\u001e";
|
private static final String RECORD_SEPARATOR = "\u001e";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkHubConnectionState() throws Exception {
|
public void checkHubConnectionState() {
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com");
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com");
|
||||||
hubConnection.start().blockingAwait(1000, TimeUnit.MILLISECONDS);
|
hubConnection.start().blockingAwait(1000, TimeUnit.MILLISECONDS);
|
||||||
assertEquals(HubConnectionState.CONNECTED, hubConnection.getConnectionState());
|
assertEquals(HubConnectionState.CONNECTED, hubConnection.getConnectionState());
|
||||||
|
|
@ -34,7 +34,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void transportCloseTriggersStopInHubConnection() throws Exception {
|
public void transportCloseTriggersStopInHubConnection() {
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
hubConnection.start().blockingAwait(1000, TimeUnit.MILLISECONDS);
|
hubConnection.start().blockingAwait(1000, TimeUnit.MILLISECONDS);
|
||||||
|
|
@ -45,7 +45,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void transportCloseWithErrorTriggersStopInHubConnection() throws Exception {
|
public void transportCloseWithErrorTriggersStopInHubConnection() {
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
AtomicReference<String> message = new AtomicReference<>();
|
AtomicReference<String> message = new AtomicReference<>();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
@ -90,7 +90,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void hubConnectionClosesAfterCloseMessage() throws Exception {
|
public void hubConnectionClosesAfterCloseMessage() {
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
||||||
|
|
@ -104,7 +104,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invalidHandShakeResponse() throws Exception {
|
public void invalidHandShakeResponse() {
|
||||||
MockTransport mockTransport = new MockTransport(false);
|
MockTransport mockTransport = new MockTransport(false);
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
||||||
|
|
@ -126,7 +126,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void registeringMultipleHandlersAndBothGetTriggered() throws Exception {
|
public void registeringMultipleHandlersAndBothGetTriggered() {
|
||||||
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
@ -151,7 +151,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void removeHandlerByName() throws Exception {
|
public void removeHandlerByName() {
|
||||||
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
@ -177,7 +177,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addAndRemoveHandlerImmediately() throws Exception {
|
public void addAndRemoveHandlerImmediately() {
|
||||||
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
@ -201,7 +201,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void removingMultipleHandlersWithOneCallToRemove() throws Exception {
|
public void removingMultipleHandlersWithOneCallToRemove() {
|
||||||
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
@ -232,7 +232,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void removeHandlerWithUnsubscribe() throws Exception {
|
public void removeHandlerWithUnsubscribe() {
|
||||||
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
@ -264,7 +264,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void unsubscribeTwice() throws Exception {
|
public void unsubscribeTwice() {
|
||||||
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
@ -297,7 +297,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void removeSingleHandlerWithUnsubscribe() throws Exception {
|
public void removeSingleHandlerWithUnsubscribe() {
|
||||||
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
@ -326,7 +326,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addAndRemoveHandlerImmediatelyWithSubscribe() throws Exception {
|
public void addAndRemoveHandlerImmediatelyWithSubscribe() {
|
||||||
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
@ -350,7 +350,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void registeringMultipleHandlersThatTakeParamsAndBothGetTriggered() throws Exception {
|
public void registeringMultipleHandlersThatTakeParamsAndBothGetTriggered() {
|
||||||
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
AtomicReference<Double> value = new AtomicReference<>(0.0);
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
@ -369,7 +369,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invokeWaitsForCompletionMessage() throws Exception {
|
public void invokeWaitsForCompletionMessage() {
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
||||||
|
|
@ -387,7 +387,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void multipleInvokesWaitForOwnCompletionMessage() throws Exception {
|
public void multipleInvokesWaitForOwnCompletionMessage() {
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
||||||
|
|
@ -413,7 +413,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invokeWorksForPrimitiveTypes() throws Exception {
|
public void invokeWorksForPrimitiveTypes() {
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
||||||
|
|
@ -432,7 +432,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void completionMessageCanHaveError() throws Exception {
|
public void completionMessageCanHaveError() {
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
||||||
|
|
@ -457,7 +457,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void stopCancelsActiveInvokes() throws Exception {
|
public void stopCancelsActiveInvokes() {
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
||||||
|
|
@ -482,7 +482,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendWithNoParamsTriggersOnHandler() throws Exception {
|
public void sendWithNoParamsTriggersOnHandler() {
|
||||||
AtomicReference<Integer> value = new AtomicReference<>(0);
|
AtomicReference<Integer> value = new AtomicReference<>(0);
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
@ -500,7 +500,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendWithParamTriggersOnHandler() throws Exception {
|
public void sendWithParamTriggersOnHandler() {
|
||||||
AtomicReference<String> value = new AtomicReference<>();
|
AtomicReference<String> value = new AtomicReference<>();
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
@ -519,7 +519,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendWithTwoParamsTriggersOnHandler() throws Exception {
|
public void sendWithTwoParamsTriggersOnHandler() {
|
||||||
AtomicReference<String> value1 = new AtomicReference<>();
|
AtomicReference<String> value1 = new AtomicReference<>();
|
||||||
AtomicReference<Double> value2 = new AtomicReference<>();
|
AtomicReference<Double> value2 = new AtomicReference<>();
|
||||||
|
|
||||||
|
|
@ -544,7 +544,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendWithThreeParamsTriggersOnHandler() throws Exception {
|
public void sendWithThreeParamsTriggersOnHandler() {
|
||||||
AtomicReference<String> value1 = new AtomicReference<>();
|
AtomicReference<String> value1 = new AtomicReference<>();
|
||||||
AtomicReference<String> value2 = new AtomicReference<>();
|
AtomicReference<String> value2 = new AtomicReference<>();
|
||||||
AtomicReference<String> value3 = new AtomicReference<>();
|
AtomicReference<String> value3 = new AtomicReference<>();
|
||||||
|
|
@ -573,7 +573,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendWithFourParamsTriggersOnHandler() throws Exception {
|
public void sendWithFourParamsTriggersOnHandler() {
|
||||||
AtomicReference<String> value1 = new AtomicReference<>();
|
AtomicReference<String> value1 = new AtomicReference<>();
|
||||||
AtomicReference<String> value2 = new AtomicReference<>();
|
AtomicReference<String> value2 = new AtomicReference<>();
|
||||||
AtomicReference<String> value3 = new AtomicReference<>();
|
AtomicReference<String> value3 = new AtomicReference<>();
|
||||||
|
|
@ -605,7 +605,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendWithFiveParamsTriggersOnHandler() throws Exception {
|
public void sendWithFiveParamsTriggersOnHandler() {
|
||||||
AtomicReference<String> value1 = new AtomicReference<>();
|
AtomicReference<String> value1 = new AtomicReference<>();
|
||||||
AtomicReference<String> value2 = new AtomicReference<>();
|
AtomicReference<String> value2 = new AtomicReference<>();
|
||||||
AtomicReference<String> value3 = new AtomicReference<>();
|
AtomicReference<String> value3 = new AtomicReference<>();
|
||||||
|
|
@ -641,7 +641,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendWithSixParamsTriggersOnHandler() throws Exception {
|
public void sendWithSixParamsTriggersOnHandler() {
|
||||||
AtomicReference<String> value1 = new AtomicReference<>();
|
AtomicReference<String> value1 = new AtomicReference<>();
|
||||||
AtomicReference<String> value2 = new AtomicReference<>();
|
AtomicReference<String> value2 = new AtomicReference<>();
|
||||||
AtomicReference<String> value3 = new AtomicReference<>();
|
AtomicReference<String> value3 = new AtomicReference<>();
|
||||||
|
|
@ -681,7 +681,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendWithSevenParamsTriggersOnHandler() throws Exception {
|
public void sendWithSevenParamsTriggersOnHandler() {
|
||||||
AtomicReference<String> value1 = new AtomicReference<>();
|
AtomicReference<String> value1 = new AtomicReference<>();
|
||||||
AtomicReference<String> value2 = new AtomicReference<>();
|
AtomicReference<String> value2 = new AtomicReference<>();
|
||||||
AtomicReference<String> value3 = new AtomicReference<>();
|
AtomicReference<String> value3 = new AtomicReference<>();
|
||||||
|
|
@ -725,7 +725,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendWithEightParamsTriggersOnHandler() throws Exception {
|
public void sendWithEightParamsTriggersOnHandler() {
|
||||||
AtomicReference<String> value1 = new AtomicReference<>();
|
AtomicReference<String> value1 = new AtomicReference<>();
|
||||||
AtomicReference<String> value2 = new AtomicReference<>();
|
AtomicReference<String> value2 = new AtomicReference<>();
|
||||||
AtomicReference<String> value3 = new AtomicReference<>();
|
AtomicReference<String> value3 = new AtomicReference<>();
|
||||||
|
|
@ -778,7 +778,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendWithCustomObjectTriggersOnHandler() throws Exception {
|
public void sendWithCustomObjectTriggersOnHandler() {
|
||||||
AtomicReference<Custom> value1 = new AtomicReference<>();
|
AtomicReference<Custom> value1 = new AtomicReference<>();
|
||||||
|
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
|
|
@ -803,7 +803,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void receiveHandshakeResponseAndMessage() throws Exception {
|
public void receiveHandshakeResponseAndMessage() {
|
||||||
AtomicReference<Double> value = new AtomicReference<Double>(0.0);
|
AtomicReference<Double> value = new AtomicReference<Double>(0.0);
|
||||||
MockTransport mockTransport = new MockTransport(false);
|
MockTransport mockTransport = new MockTransport(false);
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
|
|
@ -825,7 +825,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onClosedCallbackRunsWhenStopIsCalled() throws Exception {
|
public void onClosedCallbackRunsWhenStopIsCalled() {
|
||||||
AtomicReference<String> value1 = new AtomicReference<>();
|
AtomicReference<String> value1 = new AtomicReference<>();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com");
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com");
|
||||||
hubConnection.start();
|
hubConnection.start();
|
||||||
|
|
@ -840,7 +840,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void multipleOnClosedCallbacksRunWhenStopIsCalled() throws Exception {
|
public void multipleOnClosedCallbacksRunWhenStopIsCalled() {
|
||||||
AtomicReference<String> value1 = new AtomicReference<>();
|
AtomicReference<String> value1 = new AtomicReference<>();
|
||||||
AtomicReference<String> value2 = new AtomicReference<>();
|
AtomicReference<String> value2 = new AtomicReference<>();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com");
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com");
|
||||||
|
|
@ -866,7 +866,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void hubConnectionClosesAndRunsOnClosedCallbackAfterCloseMessageWithError() throws Exception {
|
public void hubConnectionClosesAndRunsOnClosedCallbackAfterCloseMessageWithError() {
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
hubConnection.onClosed((ex) -> {
|
hubConnection.onClosed((ex) -> {
|
||||||
|
|
@ -882,7 +882,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void callingStartOnStartedHubConnectionNoOps() throws Exception {
|
public void callingStartOnStartedHubConnectionNoOps() {
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com");
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com");
|
||||||
hubConnection.start();
|
hubConnection.start();
|
||||||
assertEquals(HubConnectionState.CONNECTED, hubConnection.getConnectionState());
|
assertEquals(HubConnectionState.CONNECTED, hubConnection.getConnectionState());
|
||||||
|
|
@ -895,16 +895,16 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void cannotSendBeforeStart() throws Exception {
|
public void cannotSendBeforeStart() {
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com");
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com");
|
||||||
assertEquals(HubConnectionState.DISCONNECTED, hubConnection.getConnectionState());
|
assertEquals(HubConnectionState.DISCONNECTED, hubConnection.getConnectionState());
|
||||||
|
|
||||||
Throwable exception = assertThrows(HubException.class, () -> hubConnection.send("inc"));
|
Throwable exception = assertThrows(RuntimeException.class, () -> hubConnection.send("inc"));
|
||||||
assertEquals("The 'send' method cannot be called if the connection is not active", exception.getMessage());
|
assertEquals("The 'send' method cannot be called if the connection is not active", exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void errorWhenReceivingInvokeWithIncorrectArgumentLength() throws Exception {
|
public void errorWhenReceivingInvokeWithIncorrectArgumentLength() {
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
hubConnection.on("Send", (s) -> {
|
hubConnection.on("Send", (s) -> {
|
||||||
|
|
@ -938,7 +938,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void negotiateThatRedirectsForeverFailsAfter100Tries() throws InterruptedException, TimeoutException, Exception {
|
public void negotiateThatRedirectsForeverFailsAfter100Tries() {
|
||||||
TestHttpClient client = new TestHttpClient().on("POST", "http://example.com/negotiate",
|
TestHttpClient client = new TestHttpClient().on("POST", "http://example.com/negotiate",
|
||||||
(req) -> CompletableFuture.completedFuture(new HttpResponse(200, "", "{\"url\":\"http://example.com\"}")));
|
(req) -> CompletableFuture.completedFuture(new HttpResponse(200, "", "{\"url\":\"http://example.com\"}")));
|
||||||
|
|
||||||
|
|
@ -953,7 +953,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void afterSuccessfulNegotiateConnectsWithTransport() throws InterruptedException, TimeoutException, Exception {
|
public void afterSuccessfulNegotiateConnectsWithTransport() {
|
||||||
TestHttpClient client = new TestHttpClient().on("POST", "http://example.com/negotiate",
|
TestHttpClient client = new TestHttpClient().on("POST", "http://example.com/negotiate",
|
||||||
(req) -> CompletableFuture.completedFuture(new HttpResponse(200, "",
|
(req) -> CompletableFuture.completedFuture(new HttpResponse(200, "",
|
||||||
"{\"connectionId\":\"bVOiRPG8-6YiJ6d7ZcTOVQ\",\""
|
"{\"connectionId\":\"bVOiRPG8-6YiJ6d7ZcTOVQ\",\""
|
||||||
|
|
@ -991,7 +991,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void negotiateRedirectIsFollowed() throws Exception {
|
public void negotiateRedirectIsFollowed() {
|
||||||
TestHttpClient client = new TestHttpClient().on("POST", "http://example.com/negotiate",
|
TestHttpClient client = new TestHttpClient().on("POST", "http://example.com/negotiate",
|
||||||
(req) -> CompletableFuture.completedFuture(new HttpResponse(200, "", "{\"url\":\"http://testexample.com/\"}")))
|
(req) -> CompletableFuture.completedFuture(new HttpResponse(200, "", "{\"url\":\"http://testexample.com/\"}")))
|
||||||
.on("POST", "http://testexample.com/negotiate",
|
.on("POST", "http://testexample.com/negotiate",
|
||||||
|
|
@ -1011,8 +1011,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void accessTokenProviderIsUsedForNegotiate()
|
public void accessTokenProviderIsUsedForNegotiate() {
|
||||||
throws InterruptedException, ExecutionException, TimeoutException, Exception {
|
|
||||||
AtomicReference<String> token = new AtomicReference<>();
|
AtomicReference<String> token = new AtomicReference<>();
|
||||||
TestHttpClient client = new TestHttpClient()
|
TestHttpClient client = new TestHttpClient()
|
||||||
.on("POST", "http://example.com/negotiate",
|
.on("POST", "http://example.com/negotiate",
|
||||||
|
|
@ -1038,7 +1037,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void accessTokenProviderIsOverriddenFromRedirectNegotiate() throws Exception {
|
public void accessTokenProviderIsOverriddenFromRedirectNegotiate() {
|
||||||
AtomicReference<String> token = new AtomicReference<>();
|
AtomicReference<String> token = new AtomicReference<>();
|
||||||
TestHttpClient client = new TestHttpClient()
|
TestHttpClient client = new TestHttpClient()
|
||||||
.on("POST", "http://example.com/negotiate", (req) -> CompletableFuture.completedFuture(new HttpResponse(200, "", "{\"url\":\"http://testexample.com/\",\"accessToken\":\"newToken\"}")))
|
.on("POST", "http://example.com/negotiate", (req) -> CompletableFuture.completedFuture(new HttpResponse(200, "", "{\"url\":\"http://testexample.com/\",\"accessToken\":\"newToken\"}")))
|
||||||
|
|
@ -1065,7 +1064,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void connectionTimesOutIfServerDoesNotSendMessage() throws Exception {
|
public void connectionTimesOutIfServerDoesNotSendMessage() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com");
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com");
|
||||||
hubConnection.setServerTimeout(Duration.ofMillis(1));
|
hubConnection.setServerTimeout(Duration.ofMillis(1));
|
||||||
hubConnection.setTickRate(Duration.ofMillis(1));
|
hubConnection.setTickRate(Duration.ofMillis(1));
|
||||||
|
|
@ -1080,7 +1079,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void connectionSendsPingsRegularly() throws InterruptedException, ExecutionException, TimeoutException, Exception {
|
public void connectionSendsPingsRegularly() throws InterruptedException {
|
||||||
MockTransport mockTransport = new MockTransport(true, false);
|
MockTransport mockTransport = new MockTransport(true, false);
|
||||||
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
HubConnection hubConnection = TestUtils.createHubConnection("http://example.com", mockTransport);
|
||||||
hubConnection.setKeepAliveInterval(Duration.ofMillis(1));
|
hubConnection.setKeepAliveInterval(Duration.ofMillis(1));
|
||||||
|
|
@ -1099,7 +1098,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void hubConnectionCanBeStartedAfterBeingStopped() throws Exception {
|
public void hubConnectionCanBeStartedAfterBeingStopped() {
|
||||||
MockTransport transport = new MockTransport();
|
MockTransport transport = new MockTransport();
|
||||||
HubConnection hubConnection = HubConnectionBuilder
|
HubConnection hubConnection = HubConnectionBuilder
|
||||||
.create("http://example.com")
|
.create("http://example.com")
|
||||||
|
|
@ -1118,7 +1117,7 @@ class HubConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void hubConnectionCanBeStartedAfterBeingStoppedAndRedirected() throws Exception {
|
public void hubConnectionCanBeStartedAfterBeingStoppedAndRedirected() {
|
||||||
MockTransport mockTransport = new MockTransport();
|
MockTransport mockTransport = new MockTransport();
|
||||||
TestHttpClient client = new TestHttpClient()
|
TestHttpClient client = new TestHttpClient()
|
||||||
.on("POST", "http://example.com/negotiate", (req) -> CompletableFuture
|
.on("POST", "http://example.com/negotiate", (req) -> CompletableFuture
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ class JsonHubProtocolTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parsePingMessage() throws Exception {
|
public void parsePingMessage() {
|
||||||
String stringifiedMessage = "{\"type\":6}\u001E";
|
String stringifiedMessage = "{\"type\":6}\u001E";
|
||||||
TestBinder binder = new TestBinder(PingMessage.getInstance());
|
TestBinder binder = new TestBinder(PingMessage.getInstance());
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@ class JsonHubProtocolTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseCloseMessage() throws Exception {
|
public void parseCloseMessage() {
|
||||||
String stringifiedMessage = "{\"type\":7}\u001E";
|
String stringifiedMessage = "{\"type\":7}\u001E";
|
||||||
TestBinder binder = new TestBinder(new CloseMessage());
|
TestBinder binder = new TestBinder(new CloseMessage());
|
||||||
|
|
||||||
|
|
@ -69,7 +69,7 @@ class JsonHubProtocolTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseCloseMessageWithError() throws Exception {
|
public void parseCloseMessageWithError() {
|
||||||
String stringifiedMessage = "{\"type\":7,\"error\": \"There was an error\"}\u001E";
|
String stringifiedMessage = "{\"type\":7,\"error\": \"There was an error\"}\u001E";
|
||||||
TestBinder binder = new TestBinder(new CloseMessage("There was an error"));
|
TestBinder binder = new TestBinder(new CloseMessage("There was an error"));
|
||||||
|
|
||||||
|
|
@ -87,7 +87,7 @@ class JsonHubProtocolTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseSingleMessage() throws Exception {
|
public void parseSingleMessage() {
|
||||||
String stringifiedMessage = "{\"type\":1,\"target\":\"test\",\"arguments\":[42]}\u001E";
|
String stringifiedMessage = "{\"type\":1,\"target\":\"test\",\"arguments\":[42]}\u001E";
|
||||||
TestBinder binder = new TestBinder(new InvocationMessage("1", "test", new Object[] { 42 }));
|
TestBinder binder = new TestBinder(new InvocationMessage("1", "test", new Object[] { 42 }));
|
||||||
|
|
||||||
|
|
@ -109,7 +109,7 @@ class JsonHubProtocolTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseSingleUnsupportedStreamItemMessage() throws Exception {
|
public void parseSingleUnsupportedStreamItemMessage() {
|
||||||
String stringifiedMessage = "{\"type\":2,\"Id\":1,\"Item\":42}\u001E";
|
String stringifiedMessage = "{\"type\":2,\"Id\":1,\"Item\":42}\u001E";
|
||||||
TestBinder binder = new TestBinder(null);
|
TestBinder binder = new TestBinder(null);
|
||||||
|
|
||||||
|
|
@ -118,7 +118,7 @@ class JsonHubProtocolTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseSingleUnsupportedStreamInvocationMessage() throws Exception {
|
public void parseSingleUnsupportedStreamInvocationMessage() {
|
||||||
String stringifiedMessage = "{\"type\":4,\"Id\":1,\"target\":\"test\",\"arguments\":[42]}\u001E";
|
String stringifiedMessage = "{\"type\":4,\"Id\":1,\"target\":\"test\",\"arguments\":[42]}\u001E";
|
||||||
TestBinder binder = new TestBinder(new StreamInvocationMessage("1", "test", new Object[] { 42 }));
|
TestBinder binder = new TestBinder(new StreamInvocationMessage("1", "test", new Object[] { 42 }));
|
||||||
|
|
||||||
|
|
@ -127,7 +127,7 @@ class JsonHubProtocolTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseSingleUnsupportedCancelInvocationMessage() throws Exception {
|
public void parseSingleUnsupportedCancelInvocationMessage() {
|
||||||
String stringifiedMessage = "{\"type\":5,\"invocationId\":123}\u001E";
|
String stringifiedMessage = "{\"type\":5,\"invocationId\":123}\u001E";
|
||||||
TestBinder binder = new TestBinder(null);
|
TestBinder binder = new TestBinder(null);
|
||||||
|
|
||||||
|
|
@ -136,7 +136,7 @@ class JsonHubProtocolTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseTwoMessages() throws Exception {
|
public void parseTwoMessages() {
|
||||||
String twoMessages = "{\"type\":1,\"target\":\"one\",\"arguments\":[42]}\u001E{\"type\":1,\"target\":\"two\",\"arguments\":[43]}\u001E";
|
String twoMessages = "{\"type\":1,\"target\":\"one\",\"arguments\":[42]}\u001E{\"type\":1,\"target\":\"two\",\"arguments\":[43]}\u001E";
|
||||||
TestBinder binder = new TestBinder(new InvocationMessage("1", "one", new Object[] { 42 }));
|
TestBinder binder = new TestBinder(new InvocationMessage("1", "one", new Object[] { 42 }));
|
||||||
|
|
||||||
|
|
@ -167,7 +167,7 @@ class JsonHubProtocolTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseSingleMessageMutipleArgs() throws Exception {
|
public void parseSingleMessageMutipleArgs() {
|
||||||
String stringifiedMessage = "{\"type\":1,\"target\":\"test\",\"arguments\":[42, 24]}\u001E";
|
String stringifiedMessage = "{\"type\":1,\"target\":\"test\",\"arguments\":[42, 24]}\u001E";
|
||||||
TestBinder binder = new TestBinder(new InvocationMessage("1", "test", new Object[] { 42, 24 }));
|
TestBinder binder = new TestBinder(new InvocationMessage("1", "test", new Object[] { 42, 24 }));
|
||||||
|
|
||||||
|
|
@ -186,7 +186,7 @@ class JsonHubProtocolTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseMessageWithOutOfOrderProperties() throws Exception {
|
public void parseMessageWithOutOfOrderProperties() {
|
||||||
String stringifiedMessage = "{\"arguments\":[42, 24],\"type\":1,\"target\":\"test\"}\u001E";
|
String stringifiedMessage = "{\"arguments\":[42, 24],\"type\":1,\"target\":\"test\"}\u001E";
|
||||||
TestBinder binder = new TestBinder(new InvocationMessage("1", "test", new Object[] { 42, 24 }));
|
TestBinder binder = new TestBinder(new InvocationMessage("1", "test", new Object[] { 42, 24 }));
|
||||||
|
|
||||||
|
|
@ -205,7 +205,7 @@ class JsonHubProtocolTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseCompletionMessageWithOutOfOrderProperties() throws Exception {
|
public void parseCompletionMessageWithOutOfOrderProperties() {
|
||||||
String stringifiedMessage = "{\"type\":3,\"result\":42,\"invocationId\":\"1\"}\u001E";
|
String stringifiedMessage = "{\"type\":3,\"result\":42,\"invocationId\":\"1\"}\u001E";
|
||||||
TestBinder binder = new TestBinder(new CompletionMessage("1", 42, null));
|
TestBinder binder = new TestBinder(new CompletionMessage("1", 42, null));
|
||||||
|
|
||||||
|
|
@ -220,7 +220,7 @@ class JsonHubProtocolTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void errorWhileParsingTooManyArgumentsWithOutOfOrderProperties() throws Exception {
|
public void errorWhileParsingTooManyArgumentsWithOutOfOrderProperties() {
|
||||||
String stringifiedMessage = "{\"arguments\":[42, 24],\"type\":1,\"target\":\"test\"}\u001E";
|
String stringifiedMessage = "{\"arguments\":[42, 24],\"type\":1,\"target\":\"test\"}\u001E";
|
||||||
TestBinder binder = new TestBinder(new InvocationMessage(null, "test", new Object[] { 42 }));
|
TestBinder binder = new TestBinder(new InvocationMessage(null, "test", new Object[] { 42 }));
|
||||||
|
|
||||||
|
|
@ -229,7 +229,7 @@ class JsonHubProtocolTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void errorWhileParsingTooManyArguments() throws Exception {
|
public void errorWhileParsingTooManyArguments() {
|
||||||
String stringifiedMessage = "{\"type\":1,\"target\":\"test\",\"arguments\":[42, 24]}\u001E";
|
String stringifiedMessage = "{\"type\":1,\"target\":\"test\",\"arguments\":[42, 24]}\u001E";
|
||||||
TestBinder binder = new TestBinder(new InvocationMessage(null, "test", new Object[] { 42 }));
|
TestBinder binder = new TestBinder(new InvocationMessage(null, "test", new Object[] { 42 }));
|
||||||
|
|
||||||
|
|
@ -238,7 +238,7 @@ class JsonHubProtocolTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void errorWhileParsingTooFewArguments() throws Exception {
|
public void errorWhileParsingTooFewArguments() {
|
||||||
String stringifiedMessage = "{\"type\":1,\"target\":\"test\",\"arguments\":[42]}\u001E";
|
String stringifiedMessage = "{\"type\":1,\"target\":\"test\",\"arguments\":[42]}\u001E";
|
||||||
TestBinder binder = new TestBinder(new InvocationMessage(null, "test", new Object[] { 42, 24 }));
|
TestBinder binder = new TestBinder(new InvocationMessage(null, "test", new Object[] { 42, 24 }));
|
||||||
|
|
||||||
|
|
@ -247,7 +247,7 @@ class JsonHubProtocolTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void errorWhileParsingIncompleteMessage() throws Exception {
|
public void errorWhileParsingIncompleteMessage() {
|
||||||
String stringifiedMessage = "{\"type\":1,\"target\":\"test\",\"arguments\":";
|
String stringifiedMessage = "{\"type\":1,\"target\":\"test\",\"arguments\":";
|
||||||
TestBinder binder = new TestBinder(new InvocationMessage(null, "test", new Object[] { 42, 24 }));
|
TestBinder binder = new TestBinder(new InvocationMessage(null, "test", new Object[] { 42, 24 }));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class MockTransport implements Transport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture start(String url) {
|
public CompletableFuture<Void> start(String url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
if (autoHandshake) {
|
if (autoHandshake) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -44,7 +44,7 @@ class MockTransport implements Transport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture send(String message) {
|
public CompletableFuture<Void> send(String message) {
|
||||||
if (!(ignorePings && message.equals("{\"type\":6}" + RECORD_SEPARATOR))) {
|
if (!(ignorePings && message.equals("{\"type\":6}" + RECORD_SEPARATOR))) {
|
||||||
sentMessages.add(message);
|
sentMessages.add(message);
|
||||||
}
|
}
|
||||||
|
|
@ -57,7 +57,7 @@ class MockTransport implements Transport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(String message) throws Exception {
|
public void onReceive(String message) {
|
||||||
this.onReceiveCallBack.invoke(message);
|
this.onReceiveCallBack.invoke(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,7 +67,7 @@ class MockTransport implements Transport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture stop() {
|
public CompletableFuture<Void> stop() {
|
||||||
onClose.accept(null);
|
onClose.accept(null);
|
||||||
return CompletableFuture.completedFuture(null);
|
return CompletableFuture.completedFuture(null);
|
||||||
}
|
}
|
||||||
|
|
@ -76,7 +76,7 @@ class MockTransport implements Transport {
|
||||||
onClose.accept(errorMessage);
|
onClose.accept(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void receiveMessage(String message) throws Exception {
|
public void receiveMessage(String message) {
|
||||||
this.onReceive(message);
|
this.onReceive(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class NegotiateResponseTest {
|
class NegotiateResponseTest {
|
||||||
@Test
|
@Test
|
||||||
public void VerifyNegotiateResponse() throws IOException {
|
public void VerifyNegotiateResponse() {
|
||||||
String stringNegotiateResponse = "{\"connectionId\":\"bVOiRPG8-6YiJ6d7ZcTOVQ\",\"" +
|
String stringNegotiateResponse = "{\"connectionId\":\"bVOiRPG8-6YiJ6d7ZcTOVQ\",\"" +
|
||||||
"availableTransports\":[{\"transport\":\"WebSockets\",\"transferFormats\":[\"Text\",\"Binary\"]}," +
|
"availableTransports\":[{\"transport\":\"WebSockets\",\"transferFormats\":[\"Text\",\"Binary\"]}," +
|
||||||
"{\"transport\":\"ServerSentEvents\",\"transferFormats\":[\"Text\"]}," +
|
"{\"transport\":\"ServerSentEvents\",\"transferFormats\":[\"Text\"]}," +
|
||||||
|
|
@ -27,7 +27,7 @@ class NegotiateResponseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void VerifyRedirectNegotiateResponse() throws IOException {
|
public void VerifyRedirectNegotiateResponse() {
|
||||||
String stringNegotiateResponse = "{\"url\":\"www.example.com\"," +
|
String stringNegotiateResponse = "{\"url\":\"www.example.com\"," +
|
||||||
"\"accessToken\":\"some_access_token\"," +
|
"\"accessToken\":\"some_access_token\"," +
|
||||||
"\"availableTransports\":[]}";
|
"\"availableTransports\":[]}";
|
||||||
|
|
@ -40,7 +40,7 @@ class NegotiateResponseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void NegotiateResponseIgnoresExtraProperties() throws IOException {
|
public void NegotiateResponseIgnoresExtraProperties() {
|
||||||
String stringNegotiateResponse = "{\"connectionId\":\"bVOiRPG8-6YiJ6d7ZcTOVQ\"," +
|
String stringNegotiateResponse = "{\"connectionId\":\"bVOiRPG8-6YiJ6d7ZcTOVQ\"," +
|
||||||
"\"extra\":\"something\"}";
|
"\"extra\":\"something\"}";
|
||||||
NegotiateResponse negotiateResponse = new NegotiateResponse(stringNegotiateResponse);
|
NegotiateResponse negotiateResponse = new NegotiateResponse(stringNegotiateResponse);
|
||||||
|
|
@ -48,7 +48,7 @@ class NegotiateResponseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void NegotiateResponseIgnoresExtraComplexProperties() throws IOException {
|
public void NegotiateResponseIgnoresExtraComplexProperties() {
|
||||||
String stringNegotiateResponse = "{\"connectionId\":\"bVOiRPG8-6YiJ6d7ZcTOVQ\"," +
|
String stringNegotiateResponse = "{\"connectionId\":\"bVOiRPG8-6YiJ6d7ZcTOVQ\"," +
|
||||||
"\"extra\":[\"something\"]}";
|
"\"extra\":[\"something\"]}";
|
||||||
NegotiateResponse negotiateResponse = new NegotiateResponse(stringNegotiateResponse);
|
NegotiateResponse negotiateResponse = new NegotiateResponse(stringNegotiateResponse);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class WebSocketTransportTest {
|
class WebSocketTransportTest {
|
||||||
@Test
|
@Test
|
||||||
public void WebsocketThrowsIfItCantConnect() throws Exception {
|
public void WebsocketThrowsIfItCantConnect() {
|
||||||
Transport transport = new WebSocketTransport(new HashMap<>(), new DefaultHttpClient(new NullLogger()), new NullLogger());
|
Transport transport = new WebSocketTransport(new HashMap<>(), new DefaultHttpClient(new NullLogger()), new NullLogger());
|
||||||
ExecutionException exception = assertThrows(ExecutionException.class, () -> transport.start("http://www.example.com").get(1, TimeUnit.SECONDS));
|
ExecutionException exception = assertThrows(ExecutionException.class, () -> transport.start("http://www.example.com").get(1, TimeUnit.SECONDS));
|
||||||
assertEquals("There was an error starting the Websockets transport.", exception.getCause().getMessage());
|
assertEquals("There was an error starting the Websockets transport.", exception.getCause().getMessage());
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import com.microsoft.signalr.HubConnectionBuilder;
|
||||||
import com.microsoft.signalr.LogLevel;
|
import com.microsoft.signalr.LogLevel;
|
||||||
|
|
||||||
public class Chat {
|
public class Chat {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) {
|
||||||
System.out.println("Enter the URL of the SignalR Chat you want to join");
|
System.out.println("Enter the URL of the SignalR Chat you want to join");
|
||||||
Scanner reader = new Scanner(System.in); // Reading from System.in
|
Scanner reader = new Scanner(System.in); // Reading from System.in
|
||||||
String input = reader.nextLine();
|
String input = reader.nextLine();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue