/// <summary> /// Refuse a connection and close the socket /// </summary> /// <param name="newModel"></param> public ReversiClientModel RefuseConnection(ReversiClientModel newModel) { // And immediately return it without updating the ID newModel.CurrentStatus = ConnectionStatusTypes.StatusConnectionRefused; try { DataTransmission.SerializeData <ReversiClientModel>(newModel, newModel.ConnectionSocket); } catch { throw new SocketException(); } newModel.ConnectionSocket.Close(); ClientDisconnectedEventArgs args = new ClientDisconnectedEventArgs { client = newModel, TimeOfDisconnect = DateTime.Now }; OnClientDisconnected(args); return(newModel); }
public static void ClientDisconnected(object sender, ClientDisconnectedEventArgs args) { window.Dispatcher.Invoke(() => { ClientViewObject.Delete(args.IpPort); }); }
private void Events_ClientDisconnected(object sender, ClientDisconnectedEventArgs e) { this.Invoke((MethodInvoker) delegate { lstClientIP.Items.Remove(e.IpPort); }); }
private void EventServerDisconnected(object sender, ClientDisconnectedEventArgs e) { foreach (ClientView view in views) { view.disconnected(); } }
private void ClientDisconnected(object sender, ClientDisconnectedEventArgs args) { Application.Current.Dispatcher.Invoke(() => { Content.Text += $"Client Disconnect\n\n"; }); }
private void OnClientDisconnected(object sender, ClientDisconnectedEventArgs e) { SaveCharacterWorldStateInPlayfab(e); RemovePlayerFromServer(e); SendToAllExcept(e.Client.ID, Tags.DespawnPlayer, new PlayerDespawnData(e.Client.ID)); }
private Task handleDisconnection(object sender, ClientDisconnectedEventArgs eventArgs) { Disconnected?.Invoke(this); Log.WriteLine("[NibriClient] Client #{0} disconnected.", Id); return(Task.CompletedTask); }
private void DisconnectedEvent(object sender, ClientDisconnectedEventArgs e) { IsConnected = false; InvokeDisconnect(); Logging.Logger?.LogWarning("[{Function}]:[{PrinterName}] Network printer connection terminated. Attempting to reconnect. Connection String: {ConnectionString}", $"{this}.{MethodBase.GetCurrentMethod().Name}", PrinterName, _settings.ConnectionString); Connect(); }
public async Task Fire_Client_Disconnected_Event() { using (var testEnvironment = CreateTestEnvironment()) { var server = await testEnvironment.StartServer(); ClientDisconnectedEventArgs eventArgs = null; server.ClientDisconnectedAsync += e => { eventArgs = e; return(PlatformAbstractionLayer.CompletedTask); }; var client = await testEnvironment.ConnectClient(o => o.WithCredentials("TheUser")); await client.DisconnectAsync(); await LongTestDelay(); Assert.IsNotNull(eventArgs); Assert.IsTrue(eventArgs.ClientId.StartsWith(nameof(Fire_Client_Disconnected_Event))); Assert.IsTrue(eventArgs.Endpoint.Contains("127.0.0.1")); Assert.AreEqual(MqttClientDisconnectType.Clean, eventArgs.DisconnectType); } }
private void Events_ClientDisconnected(object sender, ClientDisconnectedEventArgs e) { this.Invoke((MethodInvoker) delegate { txtInfo.Text += $"{e.IpPort} disconnected.{Environment.NewLine}"; lbClientIp.Items.Remove(e.IpPort); }); }
private void OnClientDisconnected(ClientDisconnectedEventArgs e) { if (ClientDisconnected != null) { ClientDisconnected(this, e); } }
private static void Networker_Disconnected(object sender, ClientDisconnectedEventArgs e) { string reason = e.Reason; if (string.IsNullOrWhiteSpace(reason)) { reason = ". No reason given."; } else { reason = ": " + reason; } if (CupboardApp.Networker.Hosting) { OldContext.ShowNotification("Info", e.RemoteEndPoint + " left the server.", duration: 3); } else { string type = reason == "Quit" ? "Info" : "Error"; OldContext.ShowNotification(type, "Disconnected from server" + reason, duration: 3, channel: "Main"); Scene.SwitchTo(_menuScene); } }
void Client_DisconnectedFromServer(object sender, ClientDisconnectedEventArgs eventArgs) { _clientList.Clear(); _sendList.Clear(); OnDisconnected(EventArgs.Empty); }
protected void ClientDisconncted(object sender, ClientDisconnectedEventArgs e) { RaiseClientDisconnected(e); TcpSession session; _sessions.TryRemove(e.Session.Guid, out session); }
internal async Task Server_ClientDisconnected(ClientDisconnectedEventArgs args) { try { var dev = await FoundDevice(args.ClientId); if (dev != null) { using (var scope = _scopeFactor.CreateScope()) using (var _dbContext = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>()) { var devtmp = _dbContext.Device.FirstOrDefault(d => d.Id == dev.Id); devtmp.LastActive = DateTime.Now; devtmp.Online = false; await _dbContext.SaveChangesAsync(); _logger.LogInformation($"Server_ClientDisconnected ClientId:{args.ClientId} DisconnectType:{args.DisconnectType} Device is {devtmp.Name }({devtmp.Id}) "); } } else { _logger.LogWarning($"Server_ClientDisconnected ClientId:{args.ClientId} DisconnectType:{args.DisconnectType}, 未能在缓存中找到"); } } catch (Exception ex) { _logger.LogError(ex, $"Server_ClientDisconnected ClientId:{args.ClientId} DisconnectType:{args.DisconnectType},{ex.Message}"); } }
private void OnDisconnect(object sender, ClientDisconnectedEventArgs e) { Server.DisconnectPeer(this); var userData = (UserData)clientData[typeof(UserData)]; Console.WriteLine($"User {userData.Id} left the game."); }
private void OnClientDisconnect(object sender, ClientDisconnectedEventArgs e) { if (isLoadingTrain) { CheckIfAllPlayersLoadedTrain(); } }
private void Events_Disconnected(object sender, ClientDisconnectedEventArgs e) { this.Invoke((MethodInvoker) delegate { txtInfo.Text += $"(Master) Servidor Desconectado. {Environment.NewLine}"; }); }
private void RaiseDisconnected(ClientDisconnectedEventArgs e) { if (Disconnected != null) { Disconnected(this, e); } }
private void OnDisconnectedFromServer(ClientDisconnectedEventArgs e) { if (DisconnectedFromServer != null) { DisconnectedFromServer(this, e); } }
private void ClientManager_ClientDisconnected(object sender, ClientDisconnectedEventArgs e) { pendingConnections.RemoveAll(x => x == e.Client.ID); e.Client.MessageReceived -= Client_MessageReceived; LeaveRoom(e.Client.ID); }
void ClientDisconnected(object sender, ClientDisconnectedEventArgs e) { players.Remove(e.Client); using (DarkRiftWriter writer = DarkRiftWriter.Create()) { writer.Write(e.Client.ID); using (Message message = Message.Create(DESPAWN_TAG, writer)) { foreach (IClient client in ClientManager.GetAllClients()) { client.SendMessage(message, SendMode.Reliable); } } } if (players.Count == 0) { testTrain = null; objects.Clear(); IDCounter = 0; InitializeTrain(); InitializeObjects(); gameStarted = false; } }
private void ClientDisconnected(object sender, ClientDisconnectedEventArgs e) { entityManager.UnregisterClient(e.Client); playerManager.UnregisterClient(e.Client); this.clients.Remove(e.Client); }
//-------------------------------------------------------------- // METHODE DECONNECTION //-------------------------------------------------------------- private void Events_Disconnected(object sender, ClientDisconnectedEventArgs e) //on reçoit la source et les données d'évènement { this.Invoke((MethodInvoker) delegate //si la deconnection est sur le thread principal { txtInfo.Text += $"Server disconnected.{Environment.NewLine}"; //ecriture:Server disconnected }); }
private void ClientDisconnected(object sender, ClientDisconnectedEventArgs e) { e.Client.MessageReceived -= SpawnObject; e.Client.MessageReceived -= SpawnObjectWithRot; e.Client.MessageReceived -= Movement; using (DarkRiftWriter writer = DarkRiftWriter.Create()) { foreach (ushort entID in clientEntitySetLookup[e.Client.ID]) { writer.Write(entID); entityCount--; freeID.Enqueue(entID); networkEntities.Remove(entID); } using (Message message = Message.Create(Tags.destroyObjectTag, writer)) { foreach (IClient client in ClientManager.GetAllClients()) { client.SendMessage(message, SendMode.Reliable); } } } clientEntitySetLookup.Remove(e.Client.ID); }
private void OnClientDisconnected(object sender, ClientDisconnectedEventArgs e) { if (this.userService.TryRemoveUser(e.SessionId)) { this.messageSenderService.NotifyEveryone($"{e.SessionId} has left.", NotificationLevel.Information); } }
private void UnRegisterClient(object sender, ClientDisconnectedEventArgs e) { e.Client.MessageReceived -= ClientAuthRequest; if (loggedInCharacters.ContainsKey(e.Client)) { LogoutClient(e.Client); } }
private void ClientDisconnectedHandler(object sender, ClientDisconnectedEventArgs eventArgs) { _synchronizationContext.Post( e => ClientDisconnectedEvent?.Invoke(this, (ClientDisconnectedEventArgs)e), eventArgs); StopNamedPipeServer(eventArgs.ClientId); }
private void OnClientDisconnected(object sender, ClientDisconnectedEventArgs e) { Logger.Info("Goodbye " + e.Client.ID); if (pendingPlayer != null && pendingPlayer.Client == e.Client) { pendingPlayer = null; } }
protected override void OnDisconnected(ClientDisconnectedEventArgs e) { base.OnDisconnected(e); Persona.Status = Status.Offline; Task.Run(() => Reconnect()); }
public static void OnClientDisconnected(object sender,ClientDisconnectedEventArgs e) { var client = (WebSocketClient) sender; //client.Socket.RemoteEndPointはアクセスできない(ソケットは閉じられている)ため、 //各自でIPEndPointを保管する必要がある。 //Because client.Socket.RemoteEndPoint is inaccecible, //you need to store IPEndPoint yourself. var ipendpoint = client_dictionary[client]; Console.WriteLine("Client [{0}] disconnected.",ipendpoint.ToString()); }
private void OnClientDisconnect(object sender, ClientDisconnectedEventArgs e) { ITcpChannel channel = e.Channel; Exception exception = e.Exception; FreeSwitch freeSwitch; if (exception != null) { if (_clients.TryGetValue(channel.ChannelId, out freeSwitch)) freeSwitch.Error(channel, exception); return; } try { _clients.TryRemove(channel.ChannelId, out freeSwitch); } catch (ArgumentNullException) { // ignored } }
/// <summary> /// Hanldes a client disconnection. Fires the relevant event ans removes its server from the pool /// </summary> private void ClientDisconnectedHandler(object sender, ClientDisconnectedEventArgs eventArgs) { OnClientDisconnected(eventArgs); StopNamedPipeServer(eventArgs.ClientId); }
public void Run() { Debug.WriteLine("やあ。"); stream.ReadTimeout = -1; Debug.WriteLine("WFD"); var message_data = new List<byte>(); var fragment_data = new List<byte>(); WebSocketFragmentOpcode? current_fragment_type = null; WebSocketFragmentInfo fragment_info = null; //ダウンロード中のフラグメント情報 while(true) { try { byte[] buf = new byte[4096]; //client.Poll(-1,SelectMode.SelectRead); int cycle_received = stream.Read(buf,0,buf.Length); if(cycle_received == 0) {//切断時 break; } Debug.WriteLine("RECEIVED {0} bytes",cycle_received); for(int i=0;i<cycle_received;i++) { Debug.WriteLine(buf[i].ToString()); } //-----データ解析----- int read_num_bytes = 0; while(cycle_received - read_num_bytes > 0) { if(fragment_info == null) { //フラグメントの必須ヘッダがない場合 //(fragment_data.Count < 2) int to_read = cycle_received - read_num_bytes>= 2 ? 2 - fragment_data.Count : cycle_received - read_num_bytes; for(int i=0; i<to_read; i++) { //最大で2バイト読み取り fragment_data.Add(buf[read_num_bytes + i]); } read_num_bytes += to_read; //読み取ったバイト数を反映 if(fragment_data.Count == 2) { //2バイトの必須ヘッダがある状態 fragment_info = WebSocketFragmentInfo. FromNecessary2Bytes(fragment_data.ToArray()); Debug.WriteLine("HEADERSIZE:"+fragment_info.CalculateSizeOfInfo().ToString()); }else{ //受信データ不足 break; } } if(fragment_info != null) { //フラグメントの必須ヘッダがある //拡張ヘッダも含めたヘッダの長さ int header_len = fragment_info.CalculateSizeOfInfo(); if(fragment_data.Count < header_len) { //ヘッダの長さが足りない //つまり未受信 or 未読 int shortage = header_len - fragment_data.Count; //不足分 int to_read = cycle_received - read_num_bytes >= shortage ? shortage : cycle_received - read_num_bytes; for(int i=0; i< to_read; i++) { //最大でshortageバイト読み取り fragment_data.Add(buf[read_num_bytes + i]); } read_num_bytes += to_read; //読み取ったバイト数を反映 if(fragment_data.Count == header_len) { //ヘッダをすべてダウンロードできた fragment_info = WebSocketFragmentInfo.FromBinary(fragment_data.ToArray()); Debug.WriteLine("PAYLOADSIZE:"+fragment_info.PayloadLength); if(fragment_info.Opcode == WebSocketFragmentOpcode.Continuation) { //前フレームの続きと言っている場合 if(current_fragment_type == null) { //前のフレームがない throw new Exception("Opcode is continuation but no former frame."); } }else{ current_fragment_type = fragment_info.Opcode; } }else{ //受信データ不足 break; } } if(fragment_data.Count >= header_len) { //ヘッダは読み込み済み //Payloadを読み込む。 int shortage = (int)fragment_info.PayloadLength - fragment_data.Count + header_len; //不足分 int to_read = cycle_received - read_num_bytes >= shortage ? shortage : cycle_received - read_num_bytes; Debug.WriteLine("COUNT:"+fragment_data.Count.ToString()); Debug.WriteLine("HEADER_LEN:"+header_len.ToString()); Debug.WriteLine("SHORTAGE_PAYLOAD:"+shortage.ToString()); for(uint i=0; i< to_read; i++) { //最大でshortageバイト読み取り fragment_data.Add(buf[read_num_bytes + i]); } read_num_bytes += to_read; //読み取ったバイト数を反映 if(fragment_data.Count == header_len + (int)fragment_info.PayloadLength) { //Payloadをすべてダウンロードできた Debug.WriteLine("FRAGMENT CLOSE"); byte[] decoded = new byte[fragment_data.Count]; for(int i = header_len; i < fragment_data.Count; i++) { //受信したペイロードをデコード(unmask) decoded[i - header_len] = (byte)(fragment_data[i] ^ fragment_info.MaskingKey[(i - header_len) % 4]); } //メッセージにプッシュ message_data.AddRange(decoded); if(fragment_info.Opcode == WebSocketFragmentOpcode.ConnectionClose) { //切断しろと言ってきた var closing_ep = (IPEndPoint)Socket.RemoteEndPoint; Debug.WriteLine("Closing connection was requested by [{0}]" ,closing_ep.ToString()); //切断する。 this.Disconnect(); Debug.WriteLine("Connection to [{0}] was closed.",closing_ep.ToString()); //切断時イベント var e = new ClientDisconnectedEventArgs(); //e.IPEndPoint = closing_ep; OnClientDisconnectedHandler(e); return; }else{ Debug.WriteLine("OPCODE:"+fragment_info.Opcode.ToString()); } if(fragment_info.FIN) { //メッセージの終わり。 Debug.WriteLine("MESSAGE END"); //メッセージの受信完了イベントを起動する var e = new MessageReceivedEventArgs(); //e.IPEndPoint = (IPEndPoint) Socket.RemoteEndPoint; e.DecodedMessage = message_data.ToArray(); OnMessageReceivedHandler(e); //メッセージを破棄 message_data.Clear(); } fragment_data.Clear(); fragment_info = null; current_fragment_type = null; }else{ //受信データ不足 break; } } } } if(cycle_received - read_num_bytes != 0) { Debug.WriteLine("尿漏れ"); } Debug.WriteLine("---------"); }catch(SocketException){ Debug.WriteLine("[{0}] SocketException occured.",((IPEndPoint)Socket.RemoteEndPoint).ToString()); } } }
private void clientDisconnected(object sender, ClientDisconnectedEventArgs arg0) { System.Console.WriteLine("Client DisConnected"); }
protected virtual void OnClientDisconnectedHandler(ClientDisconnectedEventArgs e) { var handler = OnClientDisconnected; if(handler == null) return; handler(this,e); }
public void InvokeClientDisconnected(ClientDisconnectedEventArgs ca) { ClientDisconnectedEvent handler = ClientDisconnected; if (handler != null) handler(this, ca); }
private void HandleClientDisconnected(DtpNodeSession sender, ClientDisconnectedEventArgs e) { transportNode.Shutdown(); sender.Disconnected -= HandleClientDisconnected; Completed?.Invoke(this, EventArgs.Empty); }
/* Events from clients... */ void h_Disconnected(BaseClient sender, ClientDisconnectedEventArgs e) { _RemoveClient(sender); OnClientDisconnected(new ServerClientDisconnectedEventArgs(sender, e.Exception)); }
private void OnClientDisconnected(object sender, ClientDisconnectedEventArgs e) { var client = GetClient(e.Channel); if (client != null) client.Cleanup(); //TODO: Log if we can't match the client. }
/// <summary> /// Raises the Disconnected event. /// </summary> /// <param name="e">Desired event arguments.</param> protected virtual void OnDisconnected(ClientDisconnectedEventArgs e) { ClientEventHandler<ClientDisconnectedEventArgs> handler = Disconnected; if (handler != null) { handler(this, e); } }
/// <summary> /// Löst das <see cref="ClientDisconnected"/> Ereignis aus. /// </summary> /// <param name="c">Der Remotehost, zu dem die Verbindung verloren gegangen ist.</param> /// <param name="reason">Der Grund für den Verbindungsabbruch.</param> /// <returns>Die verwendeten Ereignis Argumente.</returns> protected ClientDisconnectedEventArgs RaiseClientDisconnected(IClient c, DisconnectReason reason) { var myevent = ClientDisconnected; var args = new ClientDisconnectedEventArgs(c, reason); if (myevent != null) myevent(this, args); return args; }
/// <summary> /// Fires ClientDisconnectedEvent in the current thread /// </summary> /// <param name="eventArgs"></param> private void OnClientDisconnected(ClientDisconnectedEventArgs eventArgs) { _synchronizationContext.Post( e => ClientDisconnectedEvent.SafeInvoke(this, (ClientDisconnectedEventArgs) e), eventArgs); }