public void Join(ClientInfo sendclientInfo, byte[] JoinDate) { //Joinしてきたクライアントにグループを追加 sendclientInfo.JoinGroups.Add(ClientGroups[0]); serverCore.BroadCastNoReturn("UserJoin", JoinDate, ClientGroups); }
private async Task MainLoop() { serverCore = new ServerCore <ServerLoop>(Logger); //グループを作成 var group = Group.Create(); ClientGroups.Add(group); serverCore.ConnectionReset = (x) => { Logger.LogInformation($"{x.Name}さんが切断されました"); }; Console.WriteLine("MainLoop Start."); //すべてのIPで接続を受け付ける IPAddress ipAddress = IPAddress.Any; IPEndPoint localEndPoint = new IPEndPoint(ipAddress, PortNumber); var serverSetting = new ServerSetting { UseSSL = false }; serverSetting.LoadCertificateFile("test-cert.pfx", "testcert"); //Filter var authtificationFilter = new LocalAuthentificationFilter(); serverCore.SocketyFilters.Add(authtificationFilter); serverCore.Start(localEndPoint: localEndPoint, _stoppingCts: _stoppingCts, parent: this, _serverSetting: serverSetting); int cnt = 0; while (!_stoppingCts.IsCancellationRequested) { if (cnt++ == 5) { try { serverCore.BroadCastNoReturn("Push", null); Logger.LogInformation("Push"); } catch (Exception ex) { Logger.LogInformation(ex.ToString()); } cnt = 0; } Thread.Sleep(1000); } }