Example #1
0
        public async Task Start() {
            serviceSocket = new Socket(SocketType.Stream, ProtocolType.Tcp);
            serviceSocket.Bind(new IPEndPoint(IPAddress.Parse(this.Host),this.Port));
            serviceSocket.Listen(64);
            
            while (true) {
                Socket newSocket = await serviceSocket.AcceptSocketAsync();
                this.clientSocket.Add(newSocket);

                Task.Run(async()=>await Listen(newSocket));
            }
        }
Example #2
0
        private static void Main(string[] args)
        {
            var streamInsightAppName = ConfigurationManager.AppSettings["streamInsightAppName"];
            var streamInsightServerName = ConfigurationManager.AppSettings["streamInsightServerName"];

            var streamInsightPort = ConfigurationManager.AppSettings["streamInsightPort"];

            var serverName = ConfigurationManager.AppSettings["serverName"];

            using (var server = Microsoft.ComplexEventProcessing.Server.Create(streamInsightServerName))
            {

                var host = new ServiceHost(server.CreateManagementService());

                var managementUri = String.Format(@"http://{1}:{0}/StreamInsight/wcf/Management/", streamInsightPort, serverName);
                host.AddServiceEndpoint(typeof(IManagementService), new WSHttpBinding(SecurityMode.Message), managementUri);

                Console.WriteLine("Management URI: {0}", managementUri);
                host.Open();

                //удаляем приложение, если оно уже создано было ранее кем-то.
                if (server.Applications.ContainsKey(streamInsightAppName))
                {
                    server.Applications[streamInsightAppName].Delete();
                }
                var app = server.CreateApplication(streamInsightAppName);

                string wcfSourceUrl = String.Format(@"http://{1}:{0}/StreamInsight/wcf/Source/", streamInsightPort, serverName);

                Console.WriteLine("WCF URI: {0}", wcfSourceUrl);

                //определяем средство доставки данных клиентам.
                string signalRHubUrl = ConfigurationManager.AppSettings["signalRHubUrl"];
                var observableSink = app.DefineObserver(() => new SignalRObserver(signalRHubUrl));

                var sources = new List<IQStreamable<DiagramModelCollection>>();

                var appFabricEventQueue = new QStremableSourceNonValueEventQueue().Get(app, wcfSourceUrl);
                sources.Add(appFabricEventQueue);

                var appFabricEventValueQueue = new QStremableSourceValueEventQueue().Get(app, wcfSourceUrl);
                sources.Add(appFabricEventValueQueue);

                // var observableExceptionEventWcfSource = app.DefineObservable(() => new WCFObservable<SerializableException>(wcfSourceUrl + "ExceptionEventService", "ExceptionEventService"));

                //var query2 = from x in observableExceptionEventWcfSource
                //    .ToPointStreamable(i => PointEvent.CreateInsert<SerializableException>(DateTime.UtcNow, i), AdvanceTimeSettings.IncreasingStartTime)
                //    .TumblingWindow(TimeSpan.FromMilliseconds(30000))
                //             select x.MapEventOnDiagrams();

                //связываем источник и получатель данных
                sources.Bind(observableSink);

                host.Close();
            }
        }