static int Main(string[] args) { var listenConfig = ListenConfigModel.GetDefaults(); var userProvider = UserProvider.GetDefaults(10); var server = new ServerWrapper(listenConfig, userProvider); try { server.Listen(); } catch (Exception e) { SocketObject.GlobalLog($"Fatal exception: {e.Message}"); return(-1); } return(0); }
static async Task <int> Main(string[] args) { int maxClientCount = 1; int messageCount = 8; var connectionConfig = BaseConfigModel.GetDefaults(); var identityProvider = UserProvider.GetDefaults(maxClientCount); // Run multiple clients async int currentClientCount = 0; var tasks = new int[maxClientCount] .Select(x => Task.Run <int>(async() => { var identity = identityProvider.AuthIdentities.ElementAt(currentClientCount); var client = new ClientWrapper(connectionConfig, identity, messageCount); ++currentClientCount; try { await client.Connect(); } catch (Exception e) { SocketObject.GlobalLog(e.ToString()); return(-1); } return(client.isSuccess ? 0 : 1); })) .ToList(); await Task.WhenAll(tasks.ToArray()); // Evaluate all clients var failureCount = tasks.Count(x => x.Result != 0); SocketObject.GlobalLog($"Client failures: {failureCount}"); return(failureCount > 0 ? 1 : 0); }