public CaesuraMain() { client = new Client.Client(); server = new Server.Server(); serverThread = new Thread(new ThreadStart(server.run)); DatabaseInterface mockDatabase = mocks.Stub<DatabaseInterface>(); User zarakavaUse = new User(); zarakavaUse.setName("Zarakava"); zarakavaUse.setPass("Testing"); using (mocks.Record()) { mockDatabase.getUser("Zarakava"); LastCall.Return(zarakavaUse); mockDatabase.getUser("NULLMAN"); LastCall.Return(null); } UserRegistration.setDatabase(mockDatabase); serverThread.Start(); System.Threading.Thread.Sleep(5000); }
static void Main(string[] args) { using (var game = new Client.Client(new TeamYojig.First(), new TeamRNA.TestSquad())) { game.Run(); } }
public void Client_ConnectMultipleClientsToServer_ConnectionsSucceed() { var port = Network.GetTcpPort(); var uriString = string.Format("http://localhost:{0}", port); var uri = new Uri(uriString); var applicationContext = Substitute.For<IApplicationContext>(); using (var server = new Server.Server(uri)) { server.Start(applicationContext); var clients = new List<Client.Client>(); const int NumClients = 100; var clientReceivedMessageCount = 0; for (var i = 0; i < NumClients; i++) { var client = new Client.Client(uri); client.OnMessage += (sender, eventArgs) => clientReceivedMessageCount++; var connected = client.Connect(Client.Enums.TransportType.ServerSentEvents); Assert.IsTrue(connected); clients.Add(client); } Assert.AreEqual(NumClients, clients.Count); server.SendMessage("x"); foreach (var client in clients) { client.Dispose(); } // Probably won't receive all messages - no sleep or synchronisation implemented to ensure exactly NumClients messages Assert.IsTrue(clientReceivedMessageCount > 0); Assert.IsTrue(clientReceivedMessageCount <= NumClients); } }
static void Main(string[] args) { try { server = new Server.Server(); var listeClients = new List<Client.Client>(); for (int i = 0; i < 50; i++) { var client = new Client.Client {Nom = "Client #" + i}; client.SendMessageDone += OnSendMessageDone; listeClients.Add(client); } var listeReduite = listeClients.Skip(3).Take(40).OrderBy(client => client.Nom); foreach (var client in listeReduite) { client.SendMessage($"Message de {client.Nom} à {DateTime.Now}"); } } catch (ArgumentException exception) { System.Console.ForegroundColor = ConsoleColor.Red; System.Console.WriteLine("ERREUR : " + exception.StackTrace); } }
public void Close() { base.Close(); if (this.cli != null) this.cli.Close(); this.cli = null; }
public void TestClientTearDown() { mockConnection = null; mockSocket = null; client = null; mocks = null; }
protected Account(Client.Client client, double balance, Bank bank) { CurrentTime = DateTime.Now; Balance = balance; Client = client; Bank = bank; Doubtful = Client.Passport == null || Client.Address == null; }
public void TestClientSetUp() { mocks = new MockRepository(); mockSocket = mocks.Stub <iSocket.iSocket>(); mockConnection = mocks.DynamicMock <Client.iConnection>(); client = new Client.Client(); client.connection = mockConnection; }
private void btnDangNhap_Click(object sender, EventArgs e) { TenDangNhap = txtUser.Text; Password = txtPassword.Text; this.Hide(); Client.Client logout = new Client.Client(); logout.Show(); }
public static Answer AddressesByClient(object _client) { Client.Client client = _client as Client.Client; return(client == null ? new Answer(2, "Клиент не инициализирован") : Service.AllClientAddresses(client)); }
public void TestClientSetUp() { mocks = new MockRepository(); mockSocket = mocks.Stub<iSocket.iSocket>(); mockConnection = mocks.DynamicMock<Client.iConnection>(); client = new Client.Client(); client.connection = mockConnection; }
public void TestBalance() { var host = "localhost:8080"; var key = "KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr".LoadWif(); var client = new Client.Client(key, host); var balance = client.GetSelfBalance(); Assert.AreEqual(0, balance.Value); }
public void TestObjectGetWithoutOptions() { using var client = new Client.Client(key, host); using var source = new CancellationTokenSource(); source.CancelAfter(TimeSpan.FromMinutes(1)); var o = client.GetObject(Address, context: source.Token).Result; Assert.AreEqual(oid, o.ObjectId); }
public void TestGetExtendedACL() { using var client = new Client.Client(key, host); using var source = new CancellationTokenSource(); source.CancelAfter(10000); var eacl = client.GetEAcl(cid, context: source.Token).Result; Console.WriteLine(eacl.Table.ToString()); }
public void end() { serverThread.Abort(); serverThread = null; server.socket.close(); server = null; client = null; mocks = null; }
public void end() { serverThread.Abort(); serverThread = null; server.socket.close(); server = null; client = null; mocks = null; }
public void TestBalance() { using var client = new Client.Client(key, host); var balance = client.GetBalance().Result; Assert.AreEqual(8u, balance.Precision); Assert.AreEqual(0, balance.Value); }
public void TestBalanceWithOwner() { var address = "NiXweMv91Vz512bQw7jFNHAGBg8upVS8Qo"; using var client = new Client.Client(key, host); var balance = client.GetBalance(OwnerID.FromAddress(address)).Result; Assert.AreEqual(0, balance.Value); }
public void SetUp() { client = new Client.Client("http://127.0.0.1:8080/"); server = new StatServer(); server.ClearDatabaseAndCache(); var prefix = "http://+:8080/"; new Thread(() => server.Start(prefix)).Start(); }
public Card(Bank.Bank bank_, Client.Client client) { Random ran = new Random(); pinCode = Convert.ToString(ran.Next(1000, 9999)); cardNumber = Convert.ToString(ran.Next(1000000, 9999999)); bank = bank_; clientName = client.Name; }
public void testSimultaniousDownloadMetric() { int users = 100; Client.Client[] clients = new Client.Client[users]; times = new long[users]; ArrayList dltimes = new ArrayList(users); // Login all the clients var username = "******"; var password = "******"; for (int i = 0; i < users; i++) { clients[i] = new Client.Client(); clients[i].connect(); clients[i].login(username, password); Thread.Sleep(600); } // Create threads for them System.Threading.Thread[] threads = new System.Threading.Thread[users]; for (int i = 0; i < users; i++) { var tempClient = clients[i]; // for some reason if i pass "i" straight to the delegate it becomes the maximum value i can be (=users) // rather than what the value of i was during the loop var tempIndex = i; ThreadStart tempThreadStarter = delegate { helperSimultaniousDownload(tempClient, tempIndex); }; threads[i] = new Thread(tempThreadStarter); } // Start the DL threads foreach (Thread t in threads) { t.Start(); } // Wait for them to finish foreach (Thread t in threads) { t.Join(); } // Disconnect the clients foreach (Client.Client client in clients) { client.disconnect(); } // Generate Statistics helperSimultaniousDownloadGenerateStatistics(); }
public QueryViewModel() { _client = RunContext.Get <Client.Client>(); this.PropertyChanged += QueryViewModel_PropertyChanged; this._titles = this._modelDict.Keys.ToList(); _titles.ForEach(i => _data.Columns.Add(i, typeof(string))); this.SetStatus("查询!"); }
public void TestLocalNodeInfo() { using var client = new Client.Client(key, host); using var source = new CancellationTokenSource(); source.CancelAfter(TimeSpan.FromMinutes(1)); var ni = client.LocalNodeInfo(context: source.Token).Result; Console.WriteLine(ni.ToString()); }
public Form1(Client.Client client) { InitializeComponent(); this.client = client; client.SomeoneJoin += SomeoneJoin; client.SomeoneExit += SomeoneExit; client.SomeoneSpeakInform += SomeoneSpeakInform; client.onSomeoneMute += OnSomeoneMute; client.OnException += OnException; }
public void TestGetContainer() { using var client = new Client.Client(key, host); using var source = new CancellationTokenSource(); source.CancelAfter(10000); var container = client.GetContainer(cid, context: source.Token).Result; Assert.AreEqual(cid, container.Container.CalCulateAndGetId); Console.WriteLine(container.Container); }
public void TestEpoch() { using var client = new Client.Client(key, host); using var source = new CancellationTokenSource(); source.CancelAfter(TimeSpan.FromMinutes(1)); var epoch = client.Epoch(context: source.Token).Result; Console.WriteLine(epoch); Assert.IsTrue(0 < epoch); }
public void HandleCommand(Client.Client sender, string[] parameter) { if (sender == null) { throw new ArgumentNullException(nameof(sender)); } _AuthenticationService.LogoutClient(sender); sender.SendServerNotification(Resources.Msg_YouHaveBeenLoggedOut); }
public void TestSessionCreate() { using var client = new Client.Client(key, host); using var source = new CancellationTokenSource(); source.CancelAfter(10000); var token = client.CreateSession(ulong.MaxValue, context: source.Token).Result; Assert.AreEqual(OwnerID.FromScriptHash(key.PublicKey().PublicKeyToScriptHash()), token.Body.OwnerId); Console.WriteLine($"id={token.Body.Id.ToUUID()}, key={token.Body.SessionKey.ToByteArray().ToHexString()}"); }
public BankAccountFactory CreatCreditAccount(Client.Client client, CreditAccountInformation creditAccountInformation) { var id = Guid.NewGuid().ToString(); InformAccountIdToClient(client, id); Accounts.Add( id, new CreditAccount(client, NotValidateSum, creditAccountInformation) ); return(this); }
public void TestDeleteContainer() { var host = "localhost:8080"; var key = "KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr".LoadWif(); var client = new Client.Client(key, host); var cid = ContainerID.FromBase58String("Bun3sfMBpnjKc3Tx7SdwrMxyNi8ha8JT3dhuFGvYBRTz"); var source = new CancellationTokenSource(); source.CancelAfter(10000); client.DeleteContainer(source.Token, cid); }
public void TestListContainer() { using var client = new Client.Client(key, host); using var source = new CancellationTokenSource(); source.CancelAfter(10000); var cids = client.ListContainers(OwnerID.FromScriptHash(key.PublicKey().PublicKeyToScriptHash()), context: source.Token).Result; Console.WriteLine(string.Join(", ", cids.Select(p => p.String()))); Assert.AreEqual(1, cids.Count); Assert.AreEqual(cid.String(), cids[0].String()); }
/// <summary> /// Constructs a new BACnetPanel2 instance /// </summary> public BACnetPanel2() { RefreshInterval = TimeSpan.FromSeconds(Constants.DefaultRefreshInterval); _editorBindings = new List <IEditorBinding>(); var session = BACnetSession.Current; host = session.GetProcess <Host>(); client = new Client.Client(host); db = session.GetProcess <NetworkDatabase>(); }
public void HandleCommand(Client.Client sender, string[] parameter) { if (_AuthenticationService.TryGetSession(sender, out Session session)) { sender.SendServerNotification(string.Format(Resources.Msg_LoggedIn, session.Account.UserName)); } else { sender.SendServerNotification(Resources.Msg_NotLoggedIn); } }
public Invoice(string title, Client.Client contractor) { DateOfCreate = DateTime.Now; IdInvoice = "FAK/" + DateOfCreate.DayOfYear.ToString() + "/" + DateOfCreate.Hour.ToString() + "/" + DateOfCreate.Minute.ToString() + "/" + DateOfCreate.Second.ToString(); ChengeTitle(title); this.Contractor = contractor; ListOfProducts = new HashedSet <Item>(); Comments = "Brak komentarza"; }
static void Main(string[] args) { //for team ice there are two dlls using (var game = new Client.Client(new TeamRNA.Squad(), new TeamIce.TeamIce())) //using (var game = new Client.Client(new TeamRNA.Squad(), new TeamRNA.TestSquad())) //using (var game = new Client.Client(new TeamRNA.Squad(), new TeamYojig.First())) { game.Run(); } }
public void TestEpoch() { var host = "localhost:8080"; var key = "KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr".LoadWif(); var client = new Client.Client(key, host); var source = new CancellationTokenSource(); source.CancelAfter(TimeSpan.FromMinutes(1)); var epoch = client.Epoch(source.Token); Console.WriteLine(epoch); }
/// <summary> /// Does a quick lookup to check whether the given client is currently logged in. /// </summary> /// <param name="client">The <see cref="Client"/> for which the login state should be looked up.</param> /// <returns>True if the given <see cref="Client"/> is logged in, false if not</returns> public bool IsLoggedIn(Client.Client client) { if (client == null) { throw new ArgumentNullException(nameof(client)); } lock (_Lock) { return(_ClientIdLoggedIn[client.Id]); } }
/// <summary> /// Tries to get the <see cref="Session"/> of the given <see cref="Client"/> if one is active. /// </summary> /// <param name="client">The <see cref="Client"/> for which its <see cref="Session"/> should be found.</param> /// <param name="session">The <see cref="Session"/> that was found.</param> /// <returns>Returns true if a <see cref="Session"/> for was found for the given <see cref="Client"/>. False if not.</returns> public bool TryGetSession(Client.Client client, out Session session) { if (client == null) { throw new ArgumentNullException(nameof(client)); } lock (_Lock) { return(_SessionByClient.TryGetValue(client, out session)); } }
public void testGetFileFromSQLAndRemote() { Client.Client client = new Client.Client(); List<string> input = new List<string>(); input.Add("text"); List<String> files = client.getFromTag(input); client.connect(); client.login("Testuser", "Test"); //client.requestFile(files.First()); client.disconnect(); Assert.IsTrue(System.IO.File.Exists("C:\\Caesura\\" + files.First())); }
public Config(bool autoStartup, bool enableBackgroundMode, Client.Client client, int selectedServerIndex, int proxyServerListenPort) { AutoStartup = autoStartup; EnableBackgroundMode = enableBackgroundMode; Client = client; SelectedServerIndex = selectedServerIndex; ProxyServerListenPort = proxyServerListenPort; }
public void testNoFileFromSQL() { Client.Client client = new Client.Client(); List<string> input = new List<string>(); input.Add("nonTag"); List<String> files = client.getFromTag(input); client.connect(); client.login("Testuser", "Test"); Assert.IsTrue((files.Count < 1)); client.disconnect(); }
static void Main(string[] args) { var teams = new List<ITeam>() { //TeamFactory.Load(@"*\Engines\*.dll"), new CloudBall.Engines.Toothless.Bot(), new CloudBall.Engines.SimpleStart(), }; using (Client.Client client = new Client.Client(teams[0], teams[1])) { client.Run(); } }
static void Main(string[] args) { var teams = new List<ITeam>() { new CloudBall.Engines.LostKeysUnited.LostKeysUnited(), //TeamFactory.Load(@"*\Arena\Engines\Wolkenhondjes_6.1.dll"), new SimpleStart(), }; using (Client.Client client = new Client.Client(teams[0], teams[2])) { client.Run(); } }
static void Main(string[] args) { var teams = new List<ITeam>() { new CloudBall.Engines.Toothless.Bot(), TeamFactory.Load(@"C:\Data\CodeReview\Wolkenhondjes_6.1.dll"), new CloudBall.Engines.SimpleStart(), }; using (Client.Client client = new Client.Client(teams[0], teams[1])) { client.Run(); } }
public void testGetBadFileFromRemote() { Client.Client client = new Client.Client(); client.connect(); client.login("Testuser", "Test"); try { //client.requestFile("failFile.txt"); } finally { client.disconnect(); } }
static void Main(string[] args) { var teams = new List<ITeam>() { new CloudBall.Engines.Dummy(), //TeamFactory.Load(@"*\Engines\*.dll"), new CloudBall.Engines.GoForTheBall(), new CloudBall.Engines.SimpleStart(), new CloudBall.Engines.Stonewall(), }; using (Client.Client client = new Client.Client(teams[1], teams[3])) { client.Run(); } }
public void Client_ConnectToServerThenTerminateServer_ConnectionSucceeds() { var port = Network.GetTcpPort(); var uriString = string.Format("http://localhost:{0}", port); var uri = new Uri(uriString); var applicationContext = Substitute.For<IApplicationContext>(); var server = new Server.Server(uri); server.Start(applicationContext); using (var client = new Client.Client(uri)) { var connected = client.Connect(Client.Enums.TransportType.ServerSentEvents); Assert.IsTrue(connected); server.Dispose(); } }
static void Main(string[] args) { _logger = new ConsoleLogger(); var connectionPool = new List<string>() { "http://ess-01:9200" }; var settings = new ClientSettings(connectionPool,"event_log"); var client = new Client.Client(settings); GetStatusCode(client); var indexOperations = new IndexOperations(client); //Reindex(indexOperations); Monitor(indexOperations); System.Console.ReadLine(); //stop the monitors monitors.ForEach((m)=> m.Stop()); System.Console.ReadLine(); }
public void testLoginTransferHex() { client = new Client.Client(); client.connect(); if (System.IO.File.Exists("C:\\Caesura\\testpic.jpg")) { System.IO.File.Delete("C:\\Caesura\\testpic.jpg"); } Assert.IsFalse(System.IO.File.Exists("C:\\Caesura\\testpic.jpg")); Assert.True(client.login("Testuser", "Test")); //Assert.True(client.requestFile("testpic.jpg")); client.disconnect(); Assert.IsTrue(System.IO.File.Exists("C:\\Caesura\\testpic.jpg")); // Assert that the contents are correct Assert.AreEqual(System.IO.File.ReadAllBytes("testpic.jpg"), System.IO.File.ReadAllBytes("C:\\Caesura\\testpic.jpg")); }
void MouseClicked(int x, int y, ref GameType gameType) { mouseClick = new Rectangle(x, y, 10, 10); if (mouseClick.Intersects(client)) { //System.Diagnostics.Process.Start("C:/Users/epita/Desktop/Kspher/Client/bin/Debug/Client.exe"); Client.Client c = new Client.Client(); Thread t = new Thread(new ThreadStart(Client.Program2.Mainq)); t.Start(); t.IsBackground = true; } if (mouseClick.Intersects(lolmulti)) { System.Diagnostics.Process.Start("C:/Users/epita/Desktop/Kspher/zbra/bin/Debug/zbra.exe"); } if (mouseClick.Intersects(Bouton_Exit)) { Game1.GetGame().Exit(); } else if (mouseClick.Intersects(Bouton_Options)) { gameType = GameType.Menu_Option_Type; } else if (mouseClick.Intersects(Bouton_Solo)) { gameType = GameType.Menu_Play_Solo_Type; } else if (mouseClick.Intersects(Bouton_Multi)) { gameType = GameType.Menu_Play_Multi_Type; MediaPlayer.Stop(); MediaPlayer.Play(SoundManager.ingame); MediaPlayer.IsRepeating = true; } }
public TcpClientm(TcpClient t, ushort i) : base(t, i) { this.cli = new Client.Client(this); this.cli.onConnect(); }
/// <summary> /// Called when the refreshTimer elapses, and triggers /// a refresh of BACnet data on this panel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void _refresh(object sender, EventArgs e) { if (_refreshing) return; try { var session = BACnetSession.Current; var host = session.GetProcess<Host>(); var client = new Client.Client(host); await this.Refresh(client); } catch(BACnetException) { } catch(AggregateException) { } catch(Exception) { } finally { _refreshing = false; } }
public void testSimultaniousLoginMetric() { int users = 100; Client.Client[] clients = new Client.Client[users]; int delay = 100; times = new long[users]; // Generate the clients & connect them for (int i = 0; i < users; i++) { clients[i] = new Client.Client(); clients[i].connect(); Thread.Sleep(1); } // Create the threads System.Threading.Thread[] threads = new System.Threading.Thread[users]; var tempName = "Testuser"; var tempPassword = "******"; for (int i = 0; i < users; i++) { var tempClient = clients[i]; var tempIndex = i; ThreadStart tempThreadStarter = delegate { helperSimultaniousLogin(tempClient, tempName, tempPassword, tempIndex); }; threads[i] = new Thread(tempThreadStarter); } // start the threads foreach (Thread t in threads) { t.Start(); Thread.Sleep(delay); } // wait on the threads foreach (Thread t in threads) { t.Join(); } // Disconnect the clients for (int i = 0; i < users; i++) { clients[i].disconnect(); } // generate statistics helperSimultaniousLoginGenerateStatistics(); }
public virtual IClient HandleClientWelcome(TcpClient tcpClient) { IClient client = null; try { IClientInformation clientInformation = null; try { var handShakeCommand = CommandFactory.CreateHandShakeCommand("You are connected", "Welcome to the monkey.net", client, ServerInformation); var bytes = _commandSerializer.Serialize(handShakeCommand); var stream = tcpClient.GetStream(); stream.Write(bytes, 0, bytes.Length); stream.Flush(); } catch (Exception) { Debug.WriteLine("Error while sending welcome message"); } var timeOutStopWatch = new Stopwatch(); timeOutStopWatch.Start(); while (timeOutStopWatch.Elapsed.TotalSeconds < 30) { if (tcpClient.GetStream().DataAvailable) { var readData = _streamIOService.ReadData(tcpClient.Available, tcpClient.GetStream()); var handShakeCommand = _commandSerializer.Deserialize<HandShakeCommand>(readData); clientInformation = handShakeCommand.SenderInformation as IClientInformation; break; } Thread.Sleep(10); } timeOutStopWatch.Stop(); client = new Client.Client(tcpClient, clientInformation); ClientManager.Add(client); } catch { } return client; }
public void testSimultaniousDownloadMetric() { int users = 100; Client.Client[] clients = new Client.Client[users]; times = new long[users]; ArrayList dltimes = new ArrayList(users); // Login all the clients var username = "******"; var password = "******"; for (int i = 0; i < users; i++) { clients[i] = new Client.Client(); clients[i].connect(); clients[i].login(username, password); Thread.Sleep(600); } // Create threads for them System.Threading.Thread[] threads = new System.Threading.Thread[users]; for (int i = 0; i < users; i++) { var tempClient = clients[i]; // for some reason if i pass "i" straight to the delegate it becomes the maximum value i can be (=users) // rather than what the value of i was during the loop var tempIndex = i; ThreadStart tempThreadStarter = delegate { helperSimultaniousDownload(tempClient, tempIndex); }; threads[i] = new Thread(tempThreadStarter); } // Start the DL threads foreach (Thread t in threads) { t.Start(); } // Wait for them to finish foreach (Thread t in threads) { t.Join(); } // Disconnect the clients foreach (Client.Client client in clients) { client.disconnect(); } // Generate Statistics helperSimultaniousDownloadGenerateStatistics(); }