11using System . Net . Http ;
22using SocketIOClient . Serializer . Decapsulation ;
3+ using SocketIOClient . V2 . Infrastructure ;
34using SocketIOClient . V2 . Protocol . Http ;
45using SocketIOClient . V2 . Serializer . SystemTextJson ;
56using SocketIOClient . V2 . Session ;
@@ -10,28 +11,27 @@ namespace SocketIOClient.V2;
1011
1112public interface ISessionFactory
1213{
13- ISession New ( EngineIO eio ) ;
14+ ISession New ( EngineIO eio , SessionOptions options ) ;
1415}
1516
1617public class DefaultSessionFactory : ISessionFactory
1718{
18- public ISession New ( EngineIO eio )
19+ public ISession New ( EngineIO eio , SessionOptions options )
1920 {
20- var engineIOAdapter = NewEnginIOAdapter ( eio ) ;
2121 var httpClient = new SystemHttpClient ( new HttpClient ( ) ) ;
22+ var httpAdapter = new HttpAdapter ( httpClient ) ;
23+ var serializer = new SystemJsonSerializer ( new Decapsulator ( ) ) ;
24+ var stopwatch = new SystemStopwatch ( ) ;
25+ var random = new SystemRandom ( ) ;
26+ var randomDelayRetryPolicy = new RandomDelayRetryPolicy ( random ) ;
27+ IEngineIOAdapter engineIOAdapter = eio == EngineIO . V3
28+ ? new EngineIO3Adapter ( stopwatch , serializer , httpAdapter , options . Timeout , randomDelayRetryPolicy )
29+ : new EngineIO4Adapter ( stopwatch , httpAdapter , options . Timeout ) ;
2230 return new HttpSession (
31+ options ,
2332 engineIOAdapter ,
2433 new HttpAdapter ( httpClient ) ,
25- new SystemJsonSerializer ( new Decapsulator ( ) ) ,
34+ serializer ,
2635 new DefaultUriConverter ( ( int ) eio ) ) ;
2736 }
28-
29- private static IEngineIOAdapter NewEnginIOAdapter ( EngineIO eio )
30- {
31- if ( eio == EngineIO . V3 )
32- {
33- return new EngineIO3Adapter ( ) ;
34- }
35- return new EngineIO4Adapter ( ) ;
36- }
3737}
0 commit comments