public void ConnectClient(DummyClient client) { Task.Run(() => { log.Debug("connecting dummy " + client); _ = client.Connect("localhost", Server.Port); }); }
public override Packet processPacket(Packet packet, OakNetEndPoint endpoint) { McDataClientServerPacket mdcs = packet as McDataClientServerPacket; if (DummyClient.isHost) { DummyClient.getDummyClient(endpoint).sendData(mdcs.data); } return(null); }
public void RemoveClient(DummyClient client) { log.Debug("removing dummy " + client); if (client.ConnectionState != ServerClientArchitecture.Connection.ConnectionState.Disconnected) { client.Disconnect(); } Data.RemoveDummy(client); }
/// <summary> /// Checks if a client already exists, if not, create a dummy client /// </summary> /// <param name="ID">ID of client to create</param> private void CheckAndCreateDummyClient(int ID) { // Adds a "dummy" client if it doesn't exist if (!Clients.ContainsKey(ID)) { lock (Clients) { Clients[ID] = new DummyClient(ID); } } }
public override Packet processPacket(Packet packet, OakNetEndPoint endpoint) { if (DummyClient.isHost) { if (DummyClient.getDummyClient(endpoint).socket == null) { return(null); } try { DummyClient.getDummyClient(endpoint).socket.Shutdown(System.Net.Sockets.SocketShutdown.Both); DummyClient.getDummyClient(endpoint).socket.Close(); } catch (SocketException) { } DummyClient.getDummyClient(endpoint).socket = null; } return(null); }
public DummyClient CreateClient(string name = null) { log.Debug("creating new dummy " + name ?? ""); var client = new DummyClient(); if (name != null) { client.Name = name; } client.LogManager.InstanceName = client.Name; if (LogStream != null) { client.LogManager.Stream = LogStream; } Data.AddDummy(client); return(client); }
private static void Main(string[] args) { const ushort port = 12345; var dataStore = new DataStore(); var file = new StreamReader("../../../Assets/TestData/short.csv"); var server = new Server(port, dataStore); var client = new DummyClient(IPAddress.Parse(server.GetIPAddress()), port, file); // run the server asynchronously var serverThread = new Thread(server.Run); serverThread.Start(); // run the client asynchronously var clientThread = new Thread(client.Run); clientThread.Start(); // retrieve the contents of the data store while (true) { var data = dataStore.Dequeue(); if (data.Length != 0) { foreach (var row in data) { foreach (var f in row) { Console.Write("{0} ", f); } Console.Write("\n"); } } else { Thread.Sleep(1000); } } }
public async Task <bool> LoginAsync(string username, string password, CancellationToken ct = default(CancellationToken)) { this.senderAddress = null; this.senderPassword = null; // Logs a user in to his google account. bool loginResult = await Task <bool> .Run(() => { Console.WriteLine("Sleeping to simulate login..."); this.client = new DummyClient(); this.client.Authed = true; Thread.Sleep(500); Console.WriteLine("Sleeping done."); return(this.client.Authed); }); if (loginResult) { this.senderAddress = username; this.senderPassword = password; } return(loginResult); }
public void DisconnectClient(DummyClient client) { log.Debug("disconnecting dummy " + client); client.Disconnect(); }
public void Init() { ai = new DummyAI(); client = new DummyClient(); }
public void RemoveDummy(DummyClient dummy) { _clientDic.Remove(dummy.Id); log.Debug("dummy " + dummy + " removed"); }
public void AddDummy(DummyClient dummy) { _clientDic.Add(dummy.Id, dummy); log.Debug("dummy " + dummy + " added"); }
public void DummyCreation() { AbstractClient C = new DummyClient(1); Assert.That(C.GetMessages().Count == 0, "Dummy client's constructor error!"); }
public void Init() { m_ai = new DummyAI(); m_client = new DummyClient(); }
private static void ProcessInputLine(string input) { switch (input) { case "start": { if (_server == null) { _server = new ServerHandler(new DummyClientFactory(), new VoiceServerConfiguration("localhost", 23332, "S1u8otSWS/L/V1luEkMnupTwgeA=", 130, "123")); } Logger.Info("Starting JustAnotherVoiceChat DummyServer..."); try { _server.Start(); } catch (VoiceServerAlreadyStartedException) { Logger.Info("Server is already started!"); return; } Logger.Info("JustAnotherVoiceChat DummyServer started!"); break; } case "stop": { StopServer(); break; } case "dispose": { DisposeServer(); break; } case "stress": { Logger.Info("Serverstress started"); _server.StartStresstest(); break; } case "client": { var client = _server.PrepareClient(); _lastClient = client; Logger.Info("Prepared new client-slot: " + client.Handle.Identifer); break; } case "exit": { ExitApplication(); break; } } }