Improvements to SettingsInfo.
This commit is contained in:
parent
726fda5593
commit
4bcd7548d9
|
@ -75,8 +75,10 @@ public class SettingsInfo
|
|||
public static final int UPLOAD_BANDWIDTH = 1;
|
||||
public static final int DOWNLOAD_BANDWIDTH = 2;
|
||||
public static final int ROUND_TRIP_TIME = 3;
|
||||
public static final int MAX_STREAMS = 4;
|
||||
public static final int CONGESTION_WINDOW = 5;
|
||||
public static final int MAX_CONCURRENT_STREAMS = 4;
|
||||
public static final int CURRENT_CONGESTION_WINDOW = 5;
|
||||
public static final int DOWNLOAD_RETRANSMISSION_RATE = 6;
|
||||
public static final int INITIAL_WINDOW_SIZE = 7;
|
||||
|
||||
public static final int FLAG_PERSIST = 1 << 24;
|
||||
public static final int FLAG_PERSISTED = 2 << 24;
|
||||
|
@ -136,4 +138,8 @@ public class SettingsInfo
|
|||
return "[" + getFlags() + "," + getId() + "]";
|
||||
}
|
||||
}
|
||||
|
||||
public static class Setting
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,9 +66,7 @@ public class SettingsBodyParser extends ControlFrameBodyParser
|
|||
--cursor;
|
||||
count += (currByte & 0xFF) << 8 * cursor;
|
||||
if (cursor == 0)
|
||||
{
|
||||
state = State.KEY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KEY:
|
||||
|
|
|
@ -35,7 +35,7 @@ public class SettingsGenerateParseTest
|
|||
{
|
||||
byte flags = SettingsInfo.CLEAR_PERSISTED;
|
||||
Map<SettingsInfo.Key, Integer> pairs = new HashMap<>();
|
||||
pairs.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSIST | SettingsInfo.Key.MAX_STREAMS), 100);
|
||||
pairs.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSIST | SettingsInfo.Key.MAX_CONCURRENT_STREAMS), 100);
|
||||
pairs.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSISTED | SettingsInfo.Key.ROUND_TRIP_TIME), 500);
|
||||
SettingsFrame frame1 = new SettingsFrame(SPDY.V2, flags, pairs);
|
||||
Generator generator = new Generator(new StandardCompressionFactory().newCompressor());
|
||||
|
@ -62,7 +62,7 @@ public class SettingsGenerateParseTest
|
|||
{
|
||||
byte flags = SettingsInfo.CLEAR_PERSISTED;
|
||||
Map<SettingsInfo.Key, Integer> pairs = new HashMap<>();
|
||||
pairs.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSIST | SettingsInfo.Key.MAX_STREAMS), 100);
|
||||
pairs.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSIST | SettingsInfo.Key.MAX_CONCURRENT_STREAMS), 100);
|
||||
pairs.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSISTED | SettingsInfo.Key.ROUND_TRIP_TIME), 500);
|
||||
SettingsFrame frame1 = new SettingsFrame(SPDY.V2, flags, pairs);
|
||||
Generator generator = new Generator(new StandardCompressionFactory().newCompressor());
|
||||
|
|
|
@ -36,7 +36,7 @@ public class SettingsTest extends AbstractTest
|
|||
Map<SettingsInfo.Key,Integer> settings = new HashMap<>();
|
||||
settings.put(new SettingsInfo.Key(SettingsInfo.Key.UPLOAD_BANDWIDTH), 1024 * 1024);
|
||||
settings.put(new SettingsInfo.Key(SettingsInfo.Key.DOWNLOAD_BANDWIDTH), 1024 * 1024);
|
||||
settings.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSISTED | SettingsInfo.Key.CONGESTION_WINDOW), 1024);
|
||||
settings.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSISTED | SettingsInfo.Key.CURRENT_CONGESTION_WINDOW), 1024);
|
||||
final SettingsInfo clientSettingsInfo = new SettingsInfo(settings);
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
ServerSessionFrameListener serverSessionFrameListener = new ServerSessionFrameListener.Adapter()
|
||||
|
@ -61,7 +61,7 @@ public class SettingsTest extends AbstractTest
|
|||
Map<SettingsInfo.Key,Integer> settings = new HashMap<>();
|
||||
settings.put(new SettingsInfo.Key(SettingsInfo.Key.UPLOAD_BANDWIDTH), 1024 * 1024);
|
||||
settings.put(new SettingsInfo.Key(SettingsInfo.Key.DOWNLOAD_BANDWIDTH), 1024 * 1024);
|
||||
settings.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSIST | SettingsInfo.Key.CONGESTION_WINDOW), 1024);
|
||||
settings.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSIST | SettingsInfo.Key.CURRENT_CONGESTION_WINDOW), 1024);
|
||||
final SettingsInfo serverSettingsInfo = new SettingsInfo(settings);
|
||||
ServerSessionFrameListener serverSessionFrameListener = new ServerSessionFrameListener.Adapter()
|
||||
{
|
||||
|
@ -87,4 +87,22 @@ public class SettingsTest extends AbstractTest
|
|||
|
||||
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws Exception
|
||||
{
|
||||
startServer(new ServerSessionFrameListener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public void onConnect(Session session)
|
||||
{
|
||||
Map<SettingsInfo.Key, Integer> settings = new HashMap<>();
|
||||
settings.put(new SettingsInfo.Key(0x01_00_00_04), 25);
|
||||
settings.put(new SettingsInfo.Key(0x00_00_07_00), 49152);
|
||||
SettingsInfo settingsInfo = new SettingsInfo(settings, true);
|
||||
session.settings(settingsInfo);
|
||||
}
|
||||
});
|
||||
new CountDownLatch(1).await();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue