public NewClient ( WebSocketConnection conn ) : void | ||
conn | WebSocketConnection | The connection to use for the new client. |
return | void |
/// <summary> /// Entry point for the application. /// </summary> /// <param name="args"> /// Command-line arguments for this console application are as follows: /// /// Param 1: Server name. Cannot contain spaces. Valid characters are A-Z, a-z, 0-9, _, -, and . /// Param 2: Port number. Must be between 1000 and 65535. /// Param 3: Admin password. Cannot contain spaces. /// /// A sample run might look like this, if invoked manually: C:\> PokerServer.exe MyName 8500 MyPass /// </param> static void Main(string[] args) { if (args.Length != 3) { ExitWithError("Invalid number of command-line arguments (Password can not contain spaces)."); } int portNumber; if (!int.TryParse(args[1], out portNumber)) { ExitWithError("Port number is invalid."); } if (portNumber < 1000 || portNumber > 65535) { ExitWithError("Port number is outside valid range [1000-65535]."); } if (!Regex.IsMatch(args[0], @"^[a-zA-Z0-9_\-.]+$")) { ExitWithError("Name is invalid. Valid name characters are A-Z, a-z, 0-9, _, -, and ."); } Name = args[0]; Port = portNumber; // Set up the named pipe server and the initial async connection listener. NamedPipeServerStream nps = new NamedPipeServerStream("wss" + Process.GetCurrentProcess().Id, PipeDirection.Out, 1, PipeTransmissionMode.Message, PipeOptions.Asynchronous); nps.BeginWaitForConnection(PipeHandler, nps); cs = new CardServer(args[2]); server = new Fleck.WebSocketServer("ws://" + Environment.MachineName + ":" + Port + "/"); server.Start(s => cs.NewClient((WebSocketConnection)s)); while (true) { Console.ReadKey(); } }
/// <summary> /// Entry point for the application. /// </summary> /// <param name="args"> /// Command-line arguments for this console application are as follows: /// /// Param 1: Server name. Cannot contain spaces. Valid characters are A-Z, a-z, 0-9, _, -, and . /// Param 2: Port number. Must be between 1000 and 65535. /// Param 3: Admin password. Cannot contain spaces. /// /// A sample run might look like this, if invoked manually: C:\> PokerServer.exe MyName 8500 MyPass /// </param> static void Main(string[] args) { if (args.Length != 3) { ExitWithError("Invalid number of command-line arguments (Password can not contain spaces)."); } int portNumber; if (!int.TryParse(args[1], out portNumber)) { ExitWithError("Port number is invalid."); } if (portNumber < 1000 || portNumber > 65535) { ExitWithError("Port number is outside valid range [1000-65535]."); } if (!Regex.IsMatch(args[0], @"^[a-zA-Z0-9_\-.]+$")) { ExitWithError("Name is invalid. Valid name characters are A-Z, a-z, 0-9, _, -, and ."); } Name = args[0]; Port = portNumber; // Set up the named pipe server and the initial async connection listener. NamedPipeServerStream nps = new NamedPipeServerStream("wss" + Process.GetCurrentProcess().Id, PipeDirection.Out, 1, PipeTransmissionMode.Message, PipeOptions.Asynchronous); nps.BeginWaitForConnection(PipeHandler, nps); cs = new CardServer(args[2]); server = new Fleck.WebSocketServer("ws://" + Environment.MachineName + ":" + Port + "/"); server.Start(s => cs.NewClient((WebSocketConnection)s)); while (true) { Console.ReadKey(); } }
/// <summary> /// Entry point for the application. /// </summary> /// <param name="args"> /// Command-line arguments for this console application are as follows: /// /// Param 1: Server name. Cannot contain spaces. Valid characters are A-Z, a-z, 0-9, _, -, and . /// Param 2: Port number. Must be between 1000 and 65535. /// Param 3: Admin password. Cannot contain spaces. /// /// A sample run might look like this, if invoked manually: C:\> PokerServer.exe MyName 8500 MyPass /// </param> static void Main(string[] args) { if (args.Length != 4) { args = new string[4]; args[0] = "FC"; args[1] = "8000"; args[2] = "abcd"; args[3] = "127.0.0.1"; Console.WriteLine("Enter Room Name:"); args[0] = Console.ReadLine(); Console.WriteLine("Enter Port No Bet 8000 & 9000:"); args[1] = Console.ReadLine(); Console.WriteLine("Enter Room Password:"******"Enter Hosting IP or D for auto detect:"); args[3] = Console.ReadLine(); } int portNumber; if (!int.TryParse(args[1], out portNumber)) { ExitWithError("Port number is invalid."); } if (portNumber < 1000 || portNumber > 65535) { ExitWithError("Port number is outside valid range [1000-65535]."); } if (!Regex.IsMatch(args[0], @"^[a-zA-Z0-9_\-.]+$")) { ExitWithError("Name is invalid. Valid name characters are A-Z, a-z, 0-9, _, -, and ."); } Name = args[0]; Port = portNumber; if (args[3].Equals("D")) { if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { throw new Exception("Network not available."); } IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName()); MachineIp = host .AddressList .FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork).ToString(); } else { MachineIp = args[3]; } // Set up the named pipe server and the initial async connection listener. NamedPipeServerStream nps = new NamedPipeServerStream("wss" + Process.GetCurrentProcess().Id, PipeDirection.Out, 1, PipeTransmissionMode.Message, PipeOptions.Asynchronous); nps.BeginWaitForConnection(PipeHandler, nps); cs = new CardServer(args[2]); try { //server = new Fleck.WebSocketServer("ws://" + Environment.MachineName + ":" + Port + "/"); server = new Fleck.WebSocketServer("ws://" + MachineIp + ":" + Port + "/"); server.Start(s => cs.NewClient((WebSocketConnection)s)); Console.WriteLine("PID: " + Process.GetCurrentProcess().Id); } catch (Exception ex) { Console.WriteLine("Exception: " + ex.Message); } while (true) { Console.ReadKey(); } }