Esempio n. 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();
        }
        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);
        }
        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();
        }
Esempio n. 5
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();
        }