public WorldServer(ILogger <WorldServer> logger, WorldConfiguration configuration) : base(new ServerConfiguration(configuration.Host, configuration.Port, configuration.MaximumNumberOfConnections)) { this.logger = logger; this.worldConfiguration = configuration; this.InterClient = new ISClient(configuration); }
public WorldServer(ILogger <WorldServer> logger, WorldConfiguration configuration, IGameWorld gameWorld) : base(new ServerConfiguration(configuration.Host, configuration.Port, configuration.MaximumNumberOfConnections)) { _logger = logger; _worldConfiguration = configuration; _gameWorld = gameWorld; InterClient = new ISClient(configuration); InterClient.OnPacketArrived += InterClient_OnPacketArrived;; }
public NetIpcHost(ISClient clientInstance, string conName) : base(true, conName, false) { ISLogger.LogMessageOut += (object s, string msg) => { SendLogMessage(msg); }; client = clientInstance; client.Connected += Client_Connected; client.ConnectionError += Client_ConnectionError; client.ConnectionFailed += Client_ConnectionFailed; client.Disconnected += Client_Disconnected; listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, 56578)); listenSocket.Listen(1); ISLogger.Write("NetIpcHost: Waiting on port 56578"); listenSocket.BeginAccept(AcceptCallback, listenSocket); }
private void LoadAndStart() { try { clientInstance = new ISClient(); clientInstance.Start(new StartOptions(new System.Collections.Generic.List <string>(new string[] { "Verbose" })), WindowsDependencies.GetServiceDependencies(spMainHandle, spClipboardHandle)); clientInstance.ConnectionError += ClientInstance_ConnectionError; clientInstance.ConnectionFailed += ClientInstance_ConnectionFailed; clientInstance.Connected += ClientInstance_Connected; clientInstance.SasRequested += (object a, EventArgs b) => InputshareLibWindows.Native.Sas.SendSAS(false); clientInstance.Disconnected += ClientInstance_Disconnected; clientInstance.AutoReconnect = true; try { appHost = new NetIpcHost(clientInstance, "App connection"); }catch (Exception ex) { ISLogger.Write("Failed to create NetIPC host: " + ex.Message); } if (ConfigFile.TryReadProperty(ServiceConfigProperties.LastConnectedAddress, out string addrStr)) { if (IPEndPoint.TryParse(addrStr, out IPEndPoint addr)) { clientInstance.Connect(addr); } else { ISLogger.Write("Invalid address in config"); } } ISLogger.Write("Service started..."); } catch (Exception ex) { ISLogger.Write("LAUNCH ERROR - " + ex.Message); ISLogger.Write(ex.StackTrace); Stop(); } }
public static void Run() { Console.Title = "Inputshare client (Inactive)"; Console.Clear(); client = new ISClient(InputshareLibWindows.WindowsDependencies.GetClientDependencies()); client.ActiveClientChanged += Client_ActiveClientChanged; client.ClipboardDataCopied += Client_ClipboardDataCopied; client.Connected += Client_Connected; client.ConnectionFailed += Client_ConnectionFailed; client.ConnectionError += Client_ConnectionError; client.Disconnected += Client_Disconnected; string clientName = ""; IPEndPoint address = null; Console.WriteLine("Enter client name (leave blank to use machine name)"); clientName = Console.ReadLine(); if (string.IsNullOrEmpty(clientName)) { clientName = Environment.MachineName; } while (address == null) { Console.Clear(); Console.WriteLine("Enter server address:port"); Console.Write("Connect to: "); string addr = Console.ReadLine(); if (string.IsNullOrEmpty(addr)) { addr = "192.168.0.7:4441"; } string[] parts = addr.Split(':'); if (parts.Length != 2) { continue; } if (!IPAddress.TryParse(parts[0], out IPAddress ip)) { continue; } if (!int.TryParse(parts[1], out int p)) { continue; } if (p < 1 || p > 65535) { continue; } address = new IPEndPoint(ip, p); } Console.WriteLine("Available commands (non case sensitive):"); Console.WriteLine("For details on a command, type help followed by the command\n"); Console.WriteLine("'Connect address:port' - Connects to a server"); Console.WriteLine("'Disconnect' - Disconnects from server"); Console.WriteLine(); client.Connect(address.Address.ToString(), address.Port, clientName); while (true) { if (client.IsConnected) { Console.Write("{0}@{1}:", client.ClientName, client.ServerAddress); } else { Console.Write("Inputshare client: "); } string cmd = Console.ReadLine(); ExecCmd(cmd); } Thread.Sleep(1000); Console.Write("."); Thread.Sleep(1000); Console.Write("."); Thread.Sleep(1000); Console.Write("."); Thread.Sleep(1000); }