@@ -455,27 +455,37 @@ public NSPClientConfig GetServerClientConfig(string userId = null)
455
455
456
456
[ API ]
457
457
[ Secure ]
458
- public void SetServerClientConfig ( string userId , string config )
458
+ public void SetServerClientConfig ( string userName , string config )
459
459
{
460
460
NSPClientConfig nspClientConfig = null ;
461
- try
461
+ if ( String . IsNullOrWhiteSpace ( config ) ) //用户如果清空了配置则客户端会自行使用自己的配置文件
462
462
{
463
- nspClientConfig = config . ToObject < NSPClientConfig > ( ) ;
464
- nspClientConfig . UseServerControl = true ;
465
- nspClientConfig . ProviderAddress = HttpContext . Request . Url . Host ;
466
- nspClientConfig . ProviderWebPort = ServerContext . ServerConfig . WebAPIPort ;
467
- // nspClientConfig.ConfigPort = ServerContext.ServerConfig.ConfigPort;
468
- // nspClientConfig.ReversePort = ServerContext.ServerConfig.ReversePort;
463
+ Dbop . SetConfig ( userName , "" ) ;
469
464
}
470
- catch ( Exception e )
465
+ else
471
466
{
472
- throw new Exception ( "配置格式不正确。" ) ;
467
+ try
468
+ {
469
+ nspClientConfig = config . ToObject < NSPClientConfig > ( ) ;
470
+ nspClientConfig . UseServerControl = true ;
471
+ //nspClientConfig.ProviderAddress = HttpContext.Request.Url.Host;
472
+ // nspClientConfig.ProviderWebPort = ServerContext.ServerConfig.WebAPIPort;
473
+ // nspClientConfig.ConfigPort = ServerContext.ServerConfig.ConfigPort;
474
+ // nspClientConfig.ReversePort = ServerContext.ServerConfig.ReversePort;
475
+ }
476
+ catch ( Exception e )
477
+ {
478
+ throw new Exception ( "配置格式不正确。" ) ;
479
+ }
480
+
481
+ Dbop . SetConfig ( userName , nspClientConfig . ToJsonString ( ) ) ;
473
482
}
474
483
475
- Dbop . SetConfig ( userId , nspClientConfig . ToJsonString ( ) ) ;
476
484
//重置客户端(给客户端发送重定向请求让客户端主动重启)
477
- //var userid = Dbop.Get(userId)?.ToObject<User>().userId;
478
- //ServerContext.CloseAllSourceByClient(int.Parse(userid));
485
+ var userid = Dbop . Get ( userName ) ? . ToObject < User > ( ) . userId ;
486
+ //var popClientAsync = await ServerContext.Clients[userid].AppMap.First().Value.PopClientAsync();
487
+
488
+ ServerContext . CloseAllSourceByClient ( int . Parse ( userid ) ) ;
479
489
480
490
//ServerContext.CloseAllSourceByClient();
481
491
//return new NSPClientConfig();
0 commit comments