public ServerPingJob(IWsServer wsServer, IUserGroups userGroups, IServiceProvider provider, IRegistrationProvider registrationProvider) { this.wsServer = wsServer; this.userGroups = userGroups; this.provider = provider; this.registrationProvider = registrationProvider; }
public ConnectionOpener(IWsServer wsServer, ISettingsManager settingsManager) { _wsServer = wsServer; _settingsManager = settingsManager; _wsServer.OnStopped += HandleWsServerOnStopped; _wsServer.OnStarted += HandleWsServerOnStarted; }
static void Main(string[] args) { //WsServer wss = new WsServer(); IWsServer server = WsServerFactory .Use(new WsController()) .BuildServer(); server.Start(); }
public WsConnection(IServiceProvider provider, IWsServer server, WsClient client) { provider.Should().NotBeNull(); server.Should().NotBeNull(); client.Should().NotBeNull(); this.Provider = provider; this.Client = client; this.Server = server; this.logger = provider.Resolve_ <ILogger <WsConnection> >(); }
static void Main() { NTMinerConsole.SetIsMainUiOk(true); NTMinerConsole.DisbleQuickEditMode(); DevMode.SetDevMode(); Windows.ConsoleHandler.Register(Exit); Console.Title = $"{ServerAppType.WsServer.GetName()}_{ServerRoot.HostConfig.ThisServerAddress}"; // 通过WsServer的网络缓解对WebApiServer的外网流量的压力。WsServer调用WebApiServer的时候走内网调用节省外网带宽 RpcRoot.SetOfficialServerAddress(ServerRoot.HostConfig.RpcServerLocalAddress); // 用本节点的地址作为队列名,消费消息时根据路由键区分消息类型 string queue = $"{ServerAppType.WsServer.GetName()}.{ServerRoot.HostConfig.ThisServerAddress}"; string durableQueue = queue + MqKeyword.DurableQueueEndsWith; AbstractMqMessagePath[] mqMessagePaths = new AbstractMqMessagePath[] { new ReadOnlyUserMqMessagePath(durableQueue), new MinerSignMqMessagePath(durableQueue), new WsServerNodeMqMessagePath(queue), new OperationMqMessagePath(queue) }; if (!ServerConnection.Create(ServerAppType.WsServer, mqMessagePaths, out IServerConnection serverConfig)) { NTMinerConsole.UserError("启动失败,无法继续,因为服务器上下文创建失败"); return; } MinerClientMqSender = new MinerClientMqSender(serverConfig); SpeedDataRedis = new SpeedDataRedis(serverConfig); WsServerNodeRedis = new WsServerNodeRedis(serverConfig); OperationMqSender = new OperationMqSender(serverConfig); UserMqSender = new UserMqSender(serverConfig); _wsServerNodeMqSender = new WsServerNodeMqSender(serverConfig); WsServerNodeAddressSet = new WsServerNodeAddressSet(WsServerNodeRedis, _wsServerNodeMqSender); var minerRedis = new ReadOnlyMinerRedis(serverConfig); var userRedis = new ReadOnlyUserRedis(serverConfig); VirtualRoot.StartTimer(); RpcRoot.SetRpcUser(new RpcUser(ServerRoot.HostConfig.RpcLoginName, HashUtil.Sha1(ServerRoot.HostConfig.RpcPassword))); RpcRoot.SetIsOuterNet(false); // 构造函数中异步访问redis初始化用户列表,因为是异步的所以提前构造 ReadOnlyUserSet = new ReadOnlyUserSet(userRedis); MinerSignSet = new MinerSignSet(minerRedis); _wsServer = new SharpWsServer(ServerRoot.HostConfig); MinerClientSessionSet = new MinerClientSessionSet(_wsServer.MinerClientWsSessionsAdapter); MinerStudioSessionSet = new MinerStudioSessionSet(_wsServer.MinerStudioWsSessionsAdapter); _wsServer.Start(); VirtualRoot.RaiseEvent(new WebSocketServerStatedEvent()); _started = true; Console.ReadKey(true); Exit(); }
public Router(IWsServer wsServer, IWsClient wsClient, IEventAggregator eventAggregator) { _wsServer = wsServer; _wsClient = wsClient; _wsServer.OnMessageReceived += HandleWsServerOnMessageReceived; _wsServer.OnClosed += HandleWsServerOnClosed; _wsClient.OnMessageReceived += HandleWsClientOnMessageReceived; _eventAggregator = eventAggregator; _eventAggregator.GetEvent <SwitchRepeaterModeEvent>().Subscribe(HandleSwitchRepeaterModeEvent); _eventAggregator.GetEvent <SendPackageRequest>().Subscribe(HandleSendPackageRequest); }
public ServerCleanupJob(IWsServer wsServer, IUserGroups userGroups, IServiceProvider provider) { this.wsServer = wsServer; this.userGroups = userGroups; this.provider = provider; }
public WsContext(IWsServer wsServer, TcpClient client, string id) { this.Id = id; this.TcpClient = client; }