Example #1
0
        static void Main(string[] args)
        {
            DiffContainer.Init(100);

            var host = new WebSocketHost(typeof(Connection), new ServiceThrottlingBehavior()
            {
                MaxConcurrentSessions  = int.MaxValue,
                MaxConcurrentCalls     = int.MaxValue,
                MaxConcurrentInstances = int.MaxValue
            },
                                         new Uri("ws://localhost:9080/PolyJoin"));

            var binding =
                WebSocketHost.CreateWebSocketBinding(https: false, sendBufferSize: int.MaxValue, receiveBufferSize: int.MaxValue);

            binding.SendTimeout = TimeSpan.FromMilliseconds(5000);
            binding.OpenTimeout = TimeSpan.FromDays(1);

            host.AddWebSocketEndpoint(binding);

            Console.WriteLine("Open host");
            host.Open();

            host.Faulted += (sender, eventArgs) =>
            {
                Console.WriteLine("Host falted");
            };

            CommonService.Init();

            Console.ReadLine();

            Console.WriteLine("Close host");
            host.Close();
        }
Example #2
0
        /// <summary>
        /// Initializes the gameService.
        /// </summary>
        private static void Main()
        {
            string appName = ConfigurationManager.AppSettings["AppName"];
            string portNumber = ConfigurationManager.AppSettings["PortNumber"];
            string machineName = ConfigurationManager.AppSettings["MachineName"];
            string uriString = machineName + ":" + portNumber + "/" + appName;

            var sh = new WebSocketHost<GameService>(new Uri("ws://" + uriString));
            sh.AddWebSocketEndpoint();
            sh.Open();

            Console.WriteLine("Websocket game server listening on " + sh.Description.Endpoints[0].Address.Uri.AbsoluteUri);
            Console.WriteLine();

            Console.ForegroundColor = ConsoleColor.Yellow;

            Console.WriteLine("NOTE:");
            Console.WriteLine("1. Validate http://localhost/clientaccesspolicy.xml is accessible from the browser before running the game client.");
            Console.WriteLine("   (See detailed instructions in clientaccesspolicy.xml in the GameService project.)");
            Console.WriteLine("2. Ensure the firewall allows incoming TCP traffic on port 4502 before running the game client.");

            Console.ResetColor();

            Console.WriteLine();
            Console.WriteLine("Press Ctrl-C to terminate the game server...");

            using (ManualResetEvent manualResetEvent = new ManualResetEvent(false))
            {
                manualResetEvent.WaitOne();
            }

            sh.Close();
        }
Example #3
0
        private static void Main()
        {
            var sh = new WebSocketHost<EchoService>(new Uri("ws://" + Environment.MachineName + ":4502/echo"));
            sh.AddWebSocketEndpoint();
            sh.Open();

            Console.WriteLine("Websocket echo server listening on " + sh.Description.Endpoints[0].Address.Uri.AbsoluteUri);
            Console.WriteLine();

            Console.ForegroundColor = ConsoleColor.Yellow;

            Console.WriteLine("NOTE:");
            Console.WriteLine("1. Validate http://localhost/clientaccesspolicy.xml is accessible from the browser before running the echo client.");
            Console.WriteLine("   (See detailed instructions in clientaccesspolicy.xml in the EchoService project.)");
            Console.WriteLine("2. Ensure the firewall allows incoming TCP traffic on port 4502 before running the echo client.");

            Console.ResetColor();

            Console.WriteLine();
            Console.WriteLine("Press Ctrl-C to terminate the echo server...");

            using (ManualResetEvent manualResetEvent = new ManualResetEvent(false))
            {
                manualResetEvent.WaitOne();
            }

            sh.Close();
        }
Example #4
0
        /// <summary>
        /// Demonstrate how to create the WebSocket in WCF.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var host     = new WebSocketHost <MyWebSocketService>(new Uri("ws://localhost:8080/daenetsocket"));
            var endpoint = host.AddWebSocketEndpoint();

            host.Open();

            Console.WriteLine("Socket has been initialized. Press any key to exit.");

            Console.ReadLine();

            host.Close();
        }
 internal static void Stop()
 {
     serverLog.Close();
 }
 public void Stop()
 {
     serverLog.Close();
 }