protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            var host = new WebSocketHost(serviceType, baseAddresses);
            host.AddWebSocketEndpoint();

            return host;
        }
 protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
 {
     var host = new WebSocketHost(serviceType, baseAddresses);
     var binding = WebSocketHost.CreateWebSocketBinding(https: false, subProtocol: "chatprotocol");
     host.AddWebSocketEndpoint(binding);
     return host;
 }
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            WebSocketHost host = new WebSocketHost(serviceType, baseAddresses);

            host.AddWebSocketEndpoint();
            return(host);
        }
Example #4
0
        static void Main(string[] args)
        {
            var baseAddress = new Uri("ws://localhost:20001/EchoService2");

            using (var host = new WebSocketHost <EchoService2>(baseAddress))
            {
                host.AddWebSocketEndpoint();
                host.Open();
                Console.WriteLine(baseAddress.ToString() + " Opened ...");

                var task = new Task(() =>
                {
                    while (true)
                    {
                        System.Threading.Thread.Sleep(10000);
                        try
                        {
                            Console.WriteLine("Service Instance Count:" + EchoService2.ActivityServices.Count);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Error: " + ex.Message);
                        }
                    }
                });
                task.Start();
                Console.Read();
            }
        }
Example #5
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 #6
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 #7
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();
        }
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            var host    = new WebSocketHost(serviceType, baseAddresses);
            var binding = WebSocketHost.CreateWebSocketBinding(https: false, subProtocol: "chatprotocol");

            host.AddWebSocketEndpoint(binding);
            return(host);
        }
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            WebSocketHost host = new WebSocketHost(serviceType, baseAddresses);

            var bindingSsl = WebSocketHost.CreateWebSocketBinding(true);

            host.AddWebSocketEndpoint(bindingSsl);

            //host.AddWebSocketEndpoint();
            return(host);
        }
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            var host = new WebSocketHost(serviceType,
                new ServiceThrottlingBehavior { MaxConcurrentSessions = int.MaxValue, MaxConcurrentCalls = 20 }, baseAddresses);

            var binding = WebSocketHost.CreateWebSocketBinding(https: false, sendBufferSize: 2048, receiveBufferSize: 2048);
            binding.SendTimeout = TimeSpan.FromMilliseconds(500);
            binding.OpenTimeout = TimeSpan.FromDays(1);
            host.AddWebSocketEndpoint(binding);

            return host;
        }
        internal static void Start(string uri)
        {
            //localBind = WebSocketHost.CreateWebSocketBinding(false, 1024, 1024);
            localBind = WebSocketHost.CreateWebSocketBinding(false);
            serverLog = new WebSocketHost <WsUploadService>(new Uri(uri));
            serverLog.AddWebSocketEndpoint(localBind);
            serverLog.Credentials.UseIdentityConfiguration = true;

            serverLog.Faulted += serverChat_Faulted;
            serverLog.Opened  += serverChat_Opened;

            serverLog.Open();
        }
Example #12
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();
        }
Example #13
0
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            var host = new WebSocketHost(serviceType,
                                         new ServiceThrottlingBehavior {
                MaxConcurrentSessions = int.MaxValue, MaxConcurrentCalls = 20
            }, baseAddresses);

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

            binding.SendTimeout = TimeSpan.FromMilliseconds(500);
            binding.OpenTimeout = TimeSpan.FromDays(1);
            host.AddWebSocketEndpoint(binding);

            return(host);
        }
        public LogSocketsServer(string uri)
        {
            //localBind = WebSocketHost.CreateWebSocketBinding(false, 1024, 1024);
            localBind = WebSocketHost.CreateWebSocketBinding(false);
            serverLog = new WebSocketHost <LogOutputService>(new Uri(uri));
            serverLog.AddWebSocketEndpoint(localBind);
            serverLog.Credentials.UseIdentityConfiguration = true;

            serverLog.Faulted += (se, ev) => {
            };
            serverLog.Opened  += (se, ev) => {
                Type type = se.GetType();
                ;
            };

            serverLog.Open();
        }