Merge branch 'release/2.2'
This commit is contained in:
commit
d32a5c14e1
|
|
@ -126,15 +126,9 @@
|
|||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
<JavaBuildFiles Include="signalr-client-$(JavaClientVersion).jar;signalr-client-$(JavaClientVersion)-javadoc.jar;signalr-client-$(JavaClientVersion)-sources.jar;signalr-client-$(JavaClientVersion).pom"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Jars Include="signalr-client-$(JavaClientVersion).jar;signalr-client-$(JavaClientVersion)-javadoc.jar;signalr-client-$(JavaClientVersion)-sources.jar;" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PomFile Include="signalr-client-$(JavaClientVersion).pom" />
|
||||
<Jars Include="signalr-$(JavaClientVersion).jar;signalr-$(JavaClientVersion)-javadoc.jar;signalr-$(JavaClientVersion)-sources.jar;" />
|
||||
<PomFile Include="signalr-$(JavaClientVersion).pom" />
|
||||
<JavaBuildFiles Include="@(Jars);@(PomFile)"/>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PackJavaClient" Condition="'$(HasJdk)' == 'true'">
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ plugins {
|
|||
id 'maven'
|
||||
}
|
||||
|
||||
group 'com.microsoft.aspnetcore'
|
||||
group 'com.microsoft.aspnet'
|
||||
version '0.1.0-preview1'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
|
|
@ -31,11 +31,10 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
|
|||
task generatePOM {
|
||||
pom {
|
||||
project {
|
||||
groupId 'com.microsoft.aspnetcore'
|
||||
artifactId 'signalr'
|
||||
version '0.1.0-preview1'
|
||||
|
||||
inceptionYear '2018'
|
||||
description 'ASP.NET Core SignalR Client for Java applications'
|
||||
url 'https://github.com/aspnet/SignalR'
|
||||
name groupId + ':' + artifactId
|
||||
licenses {
|
||||
license {
|
||||
name 'The Apache Software License, Version 2.0'
|
||||
|
|
@ -43,9 +42,20 @@ task generatePOM {
|
|||
distribution 'repo'
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection 'scm:git:git://github.com/aspnet/SignalR.git'
|
||||
developerConnection 'scm:git:git://github.com/aspnet/SignalR.git'
|
||||
url 'http://github.com/aspnet/SignalR/tree/master'
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id 'microsoft'
|
||||
name 'Microsoft'
|
||||
}
|
||||
}
|
||||
}
|
||||
}.writeTo("signalr-client-0.1.0-preview1.pom")
|
||||
}.writeTo("signalr-0.1.0-preview1.pom")
|
||||
|
||||
ant.move file: "signalr-client-0.1.0-preview1.pom",
|
||||
ant.move file: "signalr-0.1.0-preview1.pom",
|
||||
todir: "${buildDir}/libs"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
rootProject.name = 'signalr-client'
|
||||
rootProject.name = 'signalr'
|
||||
include 'main'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public interface Action {
|
||||
void invoke();
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public interface Action1<T1> {
|
||||
void invoke(T1 param1);
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public interface Action2<T1, T2> {
|
||||
void invoke(T1 param1, T2 param2);
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public interface Action3<T1, T2, T3> {
|
||||
void invoke(T1 param1, T2 param2, T3 param3);
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public interface Action4<T1, T2, T3, T4> {
|
||||
void invoke(T1 param1, T2 param2, T3 param3, T4 param4);
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public interface Action5<T1, T2, T3, T4, T5> {
|
||||
void invoke(T1 param1, T2 param2, T3 param3, T4 param4, T5 param5);
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public interface Action6<T1, T2, T3, T4, T5, T6> {
|
||||
void invoke(T1 param1, T2 param2, T3 param3, T4 param4, T5 param5, T6 param6);
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public interface Action7<T1, T2, T3, T4, T5, T6, T7> {
|
||||
void invoke(T1 param1, T2 param2, T3 param3, T4 param4, T5 param5, T6 param6, T7 param7);
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public interface Action8<T1, T2, T3, T4, T5, T6, T7, T8> {
|
||||
void invoke(T1 param1, T2 param2, T3 param3, T4 param4, T5 param5, T6 param6, T7 param7, T8 param8);
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public interface ActionBase {
|
||||
void invoke(Object ... params);
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
|
@ -1,6 +1,10 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
import com.microsoft.aspnet.signalr.HubConnection;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Chat {
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public class ConsoleLogger implements Logger {
|
||||
private LogLevel logLevel;
|
||||
public ConsoleLogger(LogLevel logLevel) {
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class HandshakeProtocol {
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public class HandshakeRequestMessage {
|
||||
String protocol;
|
||||
int version;
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public class HandshakeResponseMessage {
|
||||
public String error;
|
||||
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public enum HubConnectionState {
|
||||
CONNECTED,
|
||||
DISCONNECTED,
|
||||
|
|
@ -1,9 +1,11 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
/**
|
||||
* A base class for hub messages.
|
||||
*/
|
||||
public abstract class HubMessage {
|
||||
abstract HubMessageType getMessageType();
|
||||
public abstract HubMessageType getMessageType();
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public enum HubMessageType {
|
||||
INVOCATION(1),
|
||||
STREAM_ITEM(2),
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
/**
|
||||
* A protocol abstraction for communicating with SignalR hubs.
|
||||
*/
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public class InvocationMessage extends HubMessage {
|
||||
int type = HubMessageType.INVOCATION.value;
|
||||
String invocationId;
|
||||
|
|
@ -37,7 +39,7 @@ public class InvocationMessage extends HubMessage {
|
|||
}
|
||||
|
||||
@Override
|
||||
HubMessageType getMessageType() {
|
||||
public HubMessageType getMessageType() {
|
||||
return HubMessageType.INVOCATION;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public enum LogLevel {
|
||||
Trace(0),
|
||||
Debug(1),
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public interface Logger {
|
||||
void log(LogLevel logLevel, String message);
|
||||
void log(LogLevel logLevel, String formattedMessage, Object ... args);
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public class NullLogger implements Logger {
|
||||
@Override
|
||||
public void log(LogLevel logLevel, String message) { }
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public interface OnReceiveCallBack {
|
||||
void invoke(String message) throws Exception;
|
||||
|
|
@ -1,12 +1,14 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public class PingMessage extends HubMessage {
|
||||
|
||||
int type = HubMessageType.PING.value;
|
||||
|
||||
@Override
|
||||
HubMessageType getMessageType() {
|
||||
public HubMessageType getMessageType() {
|
||||
return HubMessageType.PING;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,15 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Subscription {
|
||||
private CallbackMap handlers;
|
||||
private ActionBase action;
|
||||
private String target;
|
||||
|
||||
public Subscription(CallbackMap handlers, ActionBase action, String target) {
|
||||
this.handlers = handlers;
|
||||
this.action = action;
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public enum TransferFormat {
|
||||
Text,
|
||||
Binary
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
public interface Transport {
|
||||
void start() throws InterruptedException;
|
||||
void send(String message) throws Exception;
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import org.java_websocket.client.WebSocketClient;
|
||||
import org.java_websocket.handshake.ServerHandshake;
|
||||
package com.microsoft.aspnet.signalr;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import org.java_websocket.client.WebSocketClient;
|
||||
import org.java_websocket.handshake.ServerHandshake;
|
||||
|
||||
public class WebSocketTransport implements Transport {
|
||||
private WebSocketClient webSocketClient;
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import com.microsoft.aspnet.signalr.HandshakeProtocol;
|
||||
import com.microsoft.aspnet.signalr.HandshakeRequestMessage;
|
||||
import com.microsoft.aspnet.signalr.HandshakeResponseMessage;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.microsoft.aspnet.signalr.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.microsoft.aspnet.signalr.*;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
|
@ -57,10 +58,10 @@ public class JsonHubProtocolTest {
|
|||
//We can safely cast here because we know that it's an invocation message.
|
||||
InvocationMessage invocationMessage = (InvocationMessage) messages[0];
|
||||
|
||||
assertEquals("test", invocationMessage.target);
|
||||
assertEquals(null, invocationMessage.invocationId);
|
||||
assertEquals("test", invocationMessage.getTarget());
|
||||
assertEquals(null, invocationMessage.getInvocationId());
|
||||
|
||||
JsonArray messageResult = (JsonArray) invocationMessage.arguments[0];
|
||||
JsonArray messageResult = (JsonArray) invocationMessage.getArguments()[0];
|
||||
assertEquals(42, messageResult.getAsInt());
|
||||
}
|
||||
|
||||
|
|
@ -95,9 +96,9 @@ public class JsonHubProtocolTest {
|
|||
//Now that we know we have an invocation message we can cast the hubMessage.
|
||||
InvocationMessage invocationMessage = (InvocationMessage) messages[0];
|
||||
|
||||
assertEquals("one", invocationMessage.target);
|
||||
assertEquals(null, invocationMessage.invocationId);
|
||||
JsonArray messageResult = (JsonArray) invocationMessage.arguments[0];
|
||||
assertEquals("one", invocationMessage.getTarget());
|
||||
assertEquals(null, invocationMessage.getInvocationId());
|
||||
JsonArray messageResult = (JsonArray) invocationMessage.getArguments()[0];
|
||||
assertEquals(42, messageResult.getAsInt());
|
||||
|
||||
// Check the second message
|
||||
|
|
@ -106,9 +107,9 @@ public class JsonHubProtocolTest {
|
|||
//Now that we know we have an invocation message we can cast the hubMessage.
|
||||
InvocationMessage invocationMessage2 = (InvocationMessage) messages[1];
|
||||
|
||||
assertEquals("two", invocationMessage2.target);
|
||||
assertEquals(null, invocationMessage2.invocationId);
|
||||
JsonArray secondMessageResult = (JsonArray) invocationMessage2.arguments[0];
|
||||
assertEquals("two", invocationMessage2.getTarget());
|
||||
assertEquals(null, invocationMessage2.getInvocationId());
|
||||
JsonArray secondMessageResult = (JsonArray) invocationMessage2.getArguments()[0];
|
||||
assertEquals(43, secondMessageResult.getAsInt());
|
||||
}
|
||||
|
||||
|
|
@ -121,9 +122,9 @@ public class JsonHubProtocolTest {
|
|||
assertEquals(HubMessageType.INVOCATION, messages[0].getMessageType());
|
||||
|
||||
InvocationMessage message = (InvocationMessage)messages[0];
|
||||
assertEquals("test", message.target);
|
||||
assertEquals(null, message.invocationId);
|
||||
JsonArray messageResult = ((JsonArray) message.arguments[0]);
|
||||
assertEquals("test", message.getTarget());
|
||||
assertEquals(null, message.getInvocationId());
|
||||
JsonArray messageResult = ((JsonArray) message.getArguments()[0]);
|
||||
assertEquals(42, messageResult.get(0).getAsInt());
|
||||
assertEquals(24, messageResult.get(1).getAsInt());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import com.microsoft.aspnet.signalr.NullLogger;
|
||||
import com.microsoft.aspnet.signalr.WebSocketTransport;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,12 @@ export class HubConnectionBuilder {
|
|||
* @returns The {@link @aspnet/signalr.HubConnectionBuilder} instance, for chaining.
|
||||
*/
|
||||
public configureLogging(logger: ILogger): HubConnectionBuilder;
|
||||
/** Configures custom logging for the {@link @aspnet/signalr.HubConnection}.
|
||||
*
|
||||
* @param {LogLevel | ILogger} logging An object implementing the {@link @aspnet/signalr.ILogger} interface or {@link @aspnet/signalr.LogLevel}.
|
||||
* @returns The {@link @aspnet/signalr.HubConnectionBuilder} instance, for chaining.
|
||||
*/
|
||||
public configureLogging(logging: LogLevel | ILogger): HubConnectionBuilder;
|
||||
public configureLogging(logging: LogLevel | ILogger): HubConnectionBuilder {
|
||||
Arg.isRequired(logging, "logging");
|
||||
|
||||
|
|
|
|||
|
|
@ -428,6 +428,7 @@ namespace Microsoft.AspNetCore.SignalR.Client
|
|||
{
|
||||
CheckDisposed();
|
||||
CheckConnectionActive(nameof(StreamAsChannelCoreAsync));
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
// I just want an excuse to use 'irq' as a variable name...
|
||||
var irq = InvocationRequest.Stream(cancellationToken, returnType, _connectionState.GetNextId(), _loggerFactory, this, out channel);
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
{
|
||||
Log.ReceivedStreamItem(_logger, message);
|
||||
return connection.StreamTracker.ProcessItem(message);
|
||||
|
||||
}
|
||||
|
||||
private Task ProcessInvocation(HubConnectionContext connection,
|
||||
|
|
@ -496,9 +497,8 @@ namespace Microsoft.AspNetCore.SignalR.Internal
|
|||
{
|
||||
if (!_methods.TryGetValue(methodName, out var descriptor))
|
||||
{
|
||||
return Type.EmptyTypes;
|
||||
throw new HubException("Method does not exist.");
|
||||
}
|
||||
|
||||
return descriptor.ParameterTypes;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,10 +163,10 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
}
|
||||
|
||||
var target = ReadString(input, ref offset, "target");
|
||||
var parameterTypes = binder.GetParameterTypes(target);
|
||||
|
||||
try
|
||||
{
|
||||
var parameterTypes = binder.GetParameterTypes(target);
|
||||
var arguments = BindArguments(input, ref offset, parameterTypes, resolver);
|
||||
return ApplyHeaders(headers, new InvocationMessage(invocationId, target, arguments));
|
||||
}
|
||||
|
|
@ -182,10 +182,9 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
|||
var invocationId = ReadInvocationId(input, ref offset);
|
||||
var target = ReadString(input, ref offset, "target");
|
||||
|
||||
var parameterTypes = binder.GetParameterTypes(target);
|
||||
|
||||
try
|
||||
{
|
||||
var parameterTypes = binder.GetParameterTypes(target);
|
||||
var arguments = BindArguments(input, ref offset, parameterTypes, resolver);
|
||||
return ApplyHeaders(headers, new StreamInvocationMessage(invocationId, target, arguments));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -398,15 +398,8 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[MemberData(nameof(HubProtocolsAndTransportsAndHubPaths))]
|
||||
public async Task StreamDoesNotStartIfTokenAlreadyCanceled(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
bool ExpectedErrors(WriteContext writeContext)
|
||||
{
|
||||
return (writeContext.LoggerName == nameof(Http.Connections.Client.Internal.ServerSentEventsTransport) ||
|
||||
writeContext.LoggerName == nameof(Http.Connections.Client.Internal.LongPollingTransport)) &&
|
||||
writeContext.EventId.Name == "ErrorSending";
|
||||
}
|
||||
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartVerifiableLog(out var loggerFactory, LogLevel.Trace, $"{nameof(StreamDoesNotStartIfTokenAlreadyCanceled)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
|
||||
using (StartVerifiableLog(out var loggerFactory, LogLevel.Trace, $"{nameof(StreamDoesNotStartIfTokenAlreadyCanceled)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
|
||||
{
|
||||
var connection = CreateHubConnection(path, transportType, protocol, loggerFactory);
|
||||
try
|
||||
|
|
@ -416,10 +409,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
var cts = new CancellationTokenSource();
|
||||
cts.Cancel();
|
||||
|
||||
var channel = await connection.StreamAsChannelAsync<int>("Stream", 5, cts.Token).OrTimeout();
|
||||
|
||||
await Assert.ThrowsAnyAsync<OperationCanceledException>(() =>
|
||||
channel.WaitToReadAsync().AsTask().OrTimeout());
|
||||
await Assert.ThrowsAnyAsync<OperationCanceledException>(() =>connection.StreamAsChannelAsync<int>("Stream", 5, cts.Token).OrTimeout());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -474,7 +464,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
bool ExpectedErrors(WriteContext writeContext)
|
||||
{
|
||||
return writeContext.LoggerName == DefaultHubDispatcherLoggerName &&
|
||||
writeContext.EventId.Name == "UnknownHubMethod";
|
||||
writeContext.EventId.Name == "FailedInvokingHubMethod";
|
||||
}
|
||||
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
|
|
@ -486,7 +476,40 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
await connection.StartAsync().OrTimeout();
|
||||
|
||||
var ex = await Assert.ThrowsAsync<HubException>(() => connection.InvokeAsync("!@#$%")).OrTimeout();
|
||||
Assert.Equal("Unknown hub method '!@#$%'", ex.Message);
|
||||
Assert.Equal("Failed to invoke '!@#$%' due to an error on the server. HubException: Method does not exist.", ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
loggerFactory.CreateLogger<HubConnectionTests>().LogError(ex, "{ExceptionType} from test", ex.GetType().FullName);
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
await connection.DisposeAsync().OrTimeout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(HubProtocolsAndTransportsAndHubPaths))]
|
||||
public async Task ServerThrowsHubExceptionIfHubMethodCannotBeResolvedAndArgumentsPassedIn(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
bool ExpectedErrors(WriteContext writeContext)
|
||||
{
|
||||
return writeContext.LoggerName == DefaultHubDispatcherLoggerName &&
|
||||
writeContext.EventId.Name == "FailedInvokingHubMethod";
|
||||
}
|
||||
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (StartVerifiableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionIfHubMethodCannotBeResolvedAndArgumentsPassedIn)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
|
||||
{
|
||||
var connection = CreateHubConnection(hubPath, transportType, hubProtocol, loggerFactory);
|
||||
try
|
||||
{
|
||||
await connection.StartAsync().OrTimeout();
|
||||
|
||||
var ex = await Assert.ThrowsAsync<HubException>(() => connection.InvokeAsync("!@#$%", 10, "test")).OrTimeout();
|
||||
Assert.Equal("Failed to invoke '!@#$%' due to an error on the server. HubException: Method does not exist.", ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -573,7 +596,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
bool ExpectedErrors(WriteContext writeContext)
|
||||
{
|
||||
return writeContext.LoggerName == DefaultHubDispatcherLoggerName &&
|
||||
writeContext.EventId.Name == "UnknownHubMethod";
|
||||
writeContext.EventId.Name == "FailedInvokingHubMethod";
|
||||
}
|
||||
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
|
|
@ -586,7 +609,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
|
||||
var channel = await connection.StreamAsChannelAsync<int>("!@#$%");
|
||||
var ex = await Assert.ThrowsAsync<HubException>(() => channel.ReadAllAsync().OrTimeout());
|
||||
Assert.Equal("Unknown hub method '!@#$%'", ex.Message);
|
||||
Assert.Equal("Failed to invoke '!@#$%' due to an error on the server. HubException: Method does not exist.", ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -800,7 +800,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
|
||||
var result = await client.InvokeAsync(nameof(MethodHub.OnDisconnectedAsync)).OrTimeout();
|
||||
|
||||
Assert.Equal("Unknown hub method 'OnDisconnectedAsync'", result.Error);
|
||||
Assert.Equal("Failed to invoke 'OnDisconnectedAsync' due to an error on the server. HubException: Method does not exist.", result.Error);
|
||||
|
||||
// kill the connection
|
||||
client.Dispose();
|
||||
|
|
@ -838,7 +838,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
|
||||
var result = await client.InvokeAsync(nameof(MethodHub.StaticMethod)).OrTimeout();
|
||||
|
||||
Assert.Equal("Unknown hub method 'StaticMethod'", result.Error);
|
||||
Assert.Equal("Failed to invoke 'StaticMethod' due to an error on the server. HubException: Method does not exist.", result.Error);
|
||||
|
||||
// kill the connection
|
||||
client.Dispose();
|
||||
|
|
@ -859,16 +859,16 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
var connectionHandlerTask = await client.ConnectAsync(connectionHandler);
|
||||
|
||||
var result = await client.InvokeAsync(nameof(MethodHub.ToString)).OrTimeout();
|
||||
Assert.Equal("Unknown hub method 'ToString'", result.Error);
|
||||
Assert.Equal("Failed to invoke 'ToString' due to an error on the server. HubException: Method does not exist.", result.Error);
|
||||
|
||||
result = await client.InvokeAsync(nameof(MethodHub.GetHashCode)).OrTimeout();
|
||||
Assert.Equal("Unknown hub method 'GetHashCode'", result.Error);
|
||||
Assert.Equal("Failed to invoke 'GetHashCode' due to an error on the server. HubException: Method does not exist.", result.Error);
|
||||
|
||||
result = await client.InvokeAsync(nameof(MethodHub.Equals)).OrTimeout();
|
||||
Assert.Equal("Unknown hub method 'Equals'", result.Error);
|
||||
Assert.Equal("Failed to invoke 'Equals' due to an error on the server. HubException: Method does not exist.", result.Error);
|
||||
|
||||
result = await client.InvokeAsync(nameof(MethodHub.ReferenceEquals)).OrTimeout();
|
||||
Assert.Equal("Unknown hub method 'ReferenceEquals'", result.Error);
|
||||
Assert.Equal("Failed to invoke 'ReferenceEquals' due to an error on the server. HubException: Method does not exist.", result.Error);
|
||||
|
||||
// kill the connection
|
||||
client.Dispose();
|
||||
|
|
@ -890,7 +890,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
|
||||
var result = await client.InvokeAsync(nameof(MethodHub.Dispose)).OrTimeout();
|
||||
|
||||
Assert.Equal("Unknown hub method 'Dispose'", result.Error);
|
||||
Assert.Equal("Failed to invoke 'Dispose' due to an error on the server. HubException: Method does not exist.", result.Error);
|
||||
|
||||
// kill the connection
|
||||
client.Dispose();
|
||||
|
|
|
|||
Loading…
Reference in New Issue