public LdpPacket BuildPacket(LdpDisconnectRequest response) { var packet = LdpPacket.CreateBuilder(); packet.Type = PacketType.DISCONNECT_REQUEST; packet.DisconnectRequest = response; return packet.Build(); }
public LdpDisconnectRequest SetDisconnectRequest(DisconnectionType type) { var response = LdpDisconnectRequest.CreateBuilder(); response.Type = type; return(response.Build()); }
public LdpPacket BuildPacket(LdpDisconnectRequest response) { var packet = LdpPacket.CreateBuilder(); packet.Type = PacketType.DISCONNECT_REQUEST; packet.DisconnectRequest = response; return(packet.Build()); }
protected void DisconntectClientFromServer() { if (clientSocket != null && clientSocket.Connected) { try { var factory = new LdpProtocolPacketFactory(); var list = packetListener.GetListenersList; LdpDisconnectRequest disconnectPacket = null; LdpPacket packet = null; const int TIMEOUT = 100; if (list != null && list.Count != 0) { foreach (var item in list) { if (item is LdpRemoteDesktopSender) { disconnectPacket = factory .SetDisconnectRequest(DisconnectionType.FROM_SCREEN_THREAD); packet = factory.BuildPacket(disconnectPacket); packetSender.Send(packet); Thread.Sleep(TIMEOUT); break; } else if (item is LdpRemoteVolumeSender) { disconnectPacket = factory .SetDisconnectRequest(DisconnectionType.FROM_VOLUME_THREAD); packet = factory.BuildPacket(disconnectPacket); packetSender.Send(packet); Thread.Sleep(TIMEOUT); break; } } } disconnectPacket = factory .SetDisconnectRequest(DisconnectionType.FROM_SERVER); packet = factory.BuildPacket(disconnectPacket); packetSender.Send(packet); disconnectPacket = null; packet = null; } catch (Exception exc) { LdpLog.Error("DisconntectClient error.\n" + exc.Message); } } }