Skip to content

Commit 5a2357e

Browse files
committed
Respond to feedback
1 parent 9746105 commit 5a2357e

File tree

13 files changed

+229
-180
lines changed

13 files changed

+229
-180
lines changed

src/SignalR/clients/java/signalr/src/main/java/com/microsoft/signalr/CloseMessage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ public CloseMessage() {
1717
}
1818

1919
public CloseMessage(String error) {
20-
this (error, false);
20+
this(error, false);
2121
}
2222

2323
public CloseMessage(boolean allowReconnect) {
24-
this (null, allowReconnect);
24+
this(null, allowReconnect);
2525
}
2626

2727
public CloseMessage(String error, boolean allowReconnect) {

src/SignalR/clients/java/signalr/src/main/java/com/microsoft/signalr/HubConnection.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,6 @@ public Completable invoke(String method, Object... args) {
696696
public <T> Single<T> invoke(Class<T> returnType, String method, Object... args) {
697697
return this.<T>invoke(returnType, returnType, method, args);
698698
}
699-
700699

701700
/**
702701
* Invokes a hub method on the server using the specified method name and arguments.
@@ -1079,8 +1078,6 @@ public <T1, T2, T3, T4, T5, T6, T7, T8> Subscription on(String target, Action8<T
10791078
/**
10801079
* Registers a handler that will be invoked when the hub method with the specified method name is invoked.
10811080
* Should be used for generic classes and Parameterized Collections, like List or Map.
1082-
*
1083-
* Should be invoked with the syntax
10841081
*
10851082
* @param target The name of the hub method to define.
10861083
* @param callback The handler that will be raised when the hub method is invoked.

src/SignalR/clients/java/signalr/src/main/java/com/microsoft/signalr/InvocationBinder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
import java.util.List;
88

99
/**
10-
* An abstraction for passing around information about method signatures
10+
* An abstraction for passing around information about method signatures.
1111
*/
12-
1312
public interface InvocationBinder {
1413
Type getReturnType(String invocationId);
1514
List<Type> getParameterTypes(String methodName);

src/SignalR/clients/java/signalr/src/main/java/com/microsoft/signalr/JsonHubProtocol.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ public TransferFormat getTransferFormat() {
4141

4242
@Override
4343
public List<HubMessage> parseMessages(ByteBuffer payload, InvocationBinder binder) {
44-
String payloadStr;
45-
// If the payload is readOnly, we have to copy the bytes from its array to make the payload string
44+
String payloadStr;
45+
// If the payload is readOnly, we have to copy the bytes from its array to make the payload string
4646
if (payload.isReadOnly()) {
47-
byte[] payloadBytes = new byte[payload.remaining()];
47+
byte[] payloadBytes = new byte[payload.remaining()];
4848
payload.get(payloadBytes, 0, payloadBytes.length);
4949
payloadStr = new String(payloadBytes, StandardCharsets.UTF_8);
5050
// Otherwise we can allocate directly from its array
5151
} else {
52-
// The position of the ByteBuffer may have been incremented - make sure we only grab the remaining bytes
53-
payloadStr = new String(payload.array(), payload.position(), payload.remaining(), StandardCharsets.UTF_8);
52+
// The position of the ByteBuffer may have been incremented - make sure we only grab the remaining bytes
53+
payloadStr = new String(payload.array(), payload.position(), payload.remaining(), StandardCharsets.UTF_8);
5454
}
5555
if (payloadStr.length() == 0) {
5656
return null;

src/SignalR/clients/java/signalr/src/main/java/com/microsoft/signalr/MessagePackHubProtocol.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ private Object readValue(MessageUnpacker unpacker, Type itemType, ByteBuffer pay
616616
//Convert this to an object?
617617
item = extensionValue;
618618
*/
619-
throw new RuntimeException("Extension types are not supported yet");
619+
throw new RuntimeException("Extension types are not supported");
620620
default:
621621
return null;
622622
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
package com.microsoft.signalr;
5+
6+
import java.nio.ByteBuffer;
7+
8+
class ByteString{
9+
10+
private byte[] src;
11+
12+
private ByteString(byte[] src) {
13+
this.src = src;
14+
}
15+
16+
public static ByteString of(byte[] src) {
17+
return new ByteString(src);
18+
}
19+
20+
public static ByteString of(ByteBuffer src) {
21+
return new ByteString(src.array());
22+
}
23+
24+
public byte[] array() {
25+
return src;
26+
}
27+
28+
@Override
29+
public boolean equals(Object obj) {
30+
if (!(obj instanceof ByteString)) {
31+
return false;
32+
}
33+
byte[] otherSrc = ((ByteString) obj).array();
34+
if (otherSrc.length != src.length) {
35+
return false;
36+
}
37+
for (int i = 0; i < src.length; i++) {
38+
if (src[i] != otherSrc[i]) {
39+
return false;
40+
}
41+
}
42+
return true;
43+
}
44+
45+
@Override
46+
public String toString() {
47+
String str = "";
48+
for (byte b: src) {
49+
str += String.format("%02X", b);
50+
}
51+
return str;
52+
}
53+
}

src/SignalR/clients/java/signalr/src/test/java/com/microsoft/signalr/HandshakeProtocolTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public void VerifyCreateHandshakerequestMessage() {
1414
HandshakeRequestMessage handshakeRequest = new HandshakeRequestMessage("json", 1);
1515
ByteBuffer result = HandshakeProtocol.createHandshakeRequestMessage(handshakeRequest);
1616
String expectedResult = "{\"protocol\":\"json\",\"version\":1}\u001E";
17-
assertEquals(expectedResult, TestUtils.ByteBufferToString(result));
17+
assertEquals(expectedResult, TestUtils.byteBufferToString(result));
1818
}
1919

2020
@Test

0 commit comments

Comments
 (0)