88using System . Collections . Concurrent ;
99using System . Net ;
1010using System . Threading ;
11+ using FastChatProtocolInterface . SimpleFormulaScript ;
1112
1213namespace FastChatProtocolInterface
1314{
1415 public abstract class ExecutionMode
1516 {
1617 private static readonly ConcurrentDictionary < string , ExecutionMode ? > _modes ;
1718
18- public static ExecutionMode Server => ServerImpl . _inst ;
19+ public static ExecutionMode Server => ServerImpl . _inst_fachpi ;
1920 public static ExecutionMode Client => ClientImpl . _inst ;
2021
2122 static ExecutionMode ( )
2223 {
2324 _modes = new ( ) ;
24- _modes . TryAdd ( "server" , ServerImpl . _inst ) ;
25+ _modes . TryAdd ( "server" , ServerImpl . _inst_fachpi ) ;
26+ _modes . TryAdd ( "fachpi" , ServerImpl . _inst_fachpi ) ;
27+ _modes . TryAdd ( "sifosc" , ServerImpl . _inst_sifosc ) ;
2528 _modes . TryAdd ( "client" , ClientImpl . _inst ) ;
2629 }
2730
@@ -38,21 +41,27 @@ static ExecutionMode()
3841
3942 private sealed class ServerImpl : ExecutionMode
4043 {
41- internal static readonly ServerImpl _inst = new ( ) ;
44+ internal static readonly ServerImpl _inst_fachpi = new ( ( ip , port , name ) => new FachpiServer ( ip , port ) { Name = name } ) ;
45+ internal static readonly ServerImpl _inst_sifosc = new ( ( ip , port , name ) => new SifoscServer ( ip , port ) { Name = name } ) ;
4246
43- private ServerImpl ( ) { }
47+ private readonly Factory _factory ;
48+
49+ private ServerImpl ( Factory factory )
50+ {
51+ _factory = factory ;
52+ }
4453
4554 public override void Run ( in CommandLineArguments args )
4655 {
47- using var server = new FachpiServer ( IPAddress . Any , args . Port ) {
48- Name = args . UserName
49- } ;
56+ using var server = _factory ( IPAddress . Any , args . Port , args . UserName ) ;
5057
5158 server . Start ( ) ;
5259 while ( true ) {
5360 Thread . Yield ( ) ;
5461 }
5562 }
63+
64+ private delegate FachpiServer Factory ( IPAddress ip , int port , string name ) ;
5665 }
5766
5867 private sealed class ClientImpl : ExecutionMode
0 commit comments