public void Execute(IServiceContext context) { ignite.Logger.Log(LogLevel.Info, $">>> {nameof(EventHandlerService)} simulated initialization delay..."); Thread.Sleep(IngressRate * 2); var inCache = WaitForInputCache(); outCache = ignite.GetOrCreateCache <int, string>(CacheConfiguration(OutCache)); stateCache = ignite.GetOrCreateCache <string, int>("STATE_CACHE"); var qry = new ContinuousQuery <int, string>(new LocalListener(outCache, stateCache)); const string OffsetField = "_KEY"; var offset = stateCache.ContainsKey(LocalListener.OffsetKey) ? stateCache.Get(LocalListener.OffsetKey) : int.MaxValue; var initQry = new SqlQuery(typeof(string), $"FROM {InCache}.STRING WHERE {OffsetField} > ?") { Arguments = new[] { (object)offset } }; qryHandle = inCache.QueryContinuous(qry, initQry); foreach (var entry in qryHandle.GetInitialQueryCursor()) { LocalListener.Action(entry, outCache, stateCache); } ignite.Logger.Log(LogLevel.Info, $">>> {nameof(EventHandlerService)} is executing"); }
public static void Main() { using (var ignite = Ignition.StartFromApplicationConfiguration()) { Console.WriteLine(">>> Events example started."); Console.WriteLine(); Console.WriteLine(">>> Listening for a local event..."); ignite.GetEvents().EnableLocal(EventType.TaskExecutionAll); var listener = new LocalListener(); ignite.GetEvents().LocalListen(listener, EventType.TaskExecutionAll); ExecuteTask(ignite); ignite.GetEvents().StopLocalListen(listener); Console.WriteLine(">>> Received events count: " + listener.EventsReceived); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public static void Main() { var cfg = new IgniteConfiguration { SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml", JvmOptions = new List <string> { "-Xms512m", "-Xmx1024m" } }; using (var ignite = Ignition.Start(cfg)) { Console.WriteLine(">>> Events example started."); Console.WriteLine(); // Local listen example Console.WriteLine(">>> Listening for a local event..."); var listener = new LocalListener(); ignite.GetEvents().LocalListen(listener, EventType.TaskExecutionAll); ExecuteTask(ignite); ignite.GetEvents().StopLocalListen(listener); Console.WriteLine(">>> Received events count: " + listener.EventsReceived); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public static void Main() { var cfg = new IgniteConfiguration { SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml", JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"} }; using (var ignite = Ignition.Start(cfg)) { Console.WriteLine(">>> Events example started."); Console.WriteLine(); // Local listen example Console.WriteLine(">>> Listening for a local event..."); var listener = new LocalListener(); ignite.GetEvents().LocalListen(listener, EventType.TaskExecutionAll); ExecuteTask(ignite); ignite.GetEvents().StopLocalListen(listener); Console.WriteLine(">>> Received events count: " + listener.EventsReceived); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public static void Main() { using (var ignite = Ignition.StartFromApplicationConfiguration()) { Console.WriteLine(">>> Events example started."); Console.WriteLine(); // Local listen example Console.WriteLine(">>> Listening for a local event..."); ignite.GetEvents().EnableLocal(EventType.TaskExecutionAll); var listener = new LocalListener(); ignite.GetEvents().LocalListen(listener, EventType.TaskExecutionAll); ExecuteTask(ignite); ignite.GetEvents().StopLocalListen(listener); Console.WriteLine(">>> Received events count: " + listener.EventsReceived); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public static void Main() { using (var ignite = Ignition.Start(@"platforms\dotnet\examples\config\examples-config.xml")) { Console.WriteLine(">>> Events example started."); Console.WriteLine(); // Local listen example Console.WriteLine(">>> Listening for a local event..."); var listener = new LocalListener(); ignite.GetEvents().LocalListen(listener, EventType.TaskExecutionAll); ExecuteTask(ignite); ignite.GetEvents().StopLocalListen(listener); Console.WriteLine(">>> Received events count: " + listener.EventsReceived); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public void Start() { this.broadcaster = gameObject.AddComponent<LocalBroadcaster>(); this.listener = gameObject.AddComponent<LocalListener>(); }
public void Start() { this.broadcaster = gameObject.AddComponent <LocalBroadcaster>(); this.listener = gameObject.AddComponent <LocalListener>(); }
private void ServerAction(string strSocksIP, int socksPort, int localPort) { Reactor.Loop.Start(System.Threading.SynchronizationContext.Current); notifyln("Ready for local connection."); notifyln(String.Format("Please point your application's proxy settings to 127.0.0.1:{0}", localPort)); Reactor.Tcp.Server.Create(LocalListener => { Reactor.Tcp.Socket ProxyClient = Reactor.Tcp.Socket.Create(strSocksIP, socksPort); notifyln("Attempting to connect to proxy server..."); LocalListener.OnData += (data) => { notifyln(data.ToString(Encoding.ASCII)); }; LocalListener.OnConnect += () => { notifyln(String.Format("Received connection on 127.0.0.1:{0}", localPort)); }; LocalListener.OnError += (error) => { ProxyClient.End(); notifyln("Connection on local listener dropped:"); notifyln(error.Message); }; LocalListener.OnEnd += () => { ServerAction(strSocksIP, socksPort, localPort); LocalListener.End(); ProxyClient.End(); }; ProxyClient.OnEnd += () => { LocalListener.End(); notifyln("Connection to proxy server dropped (Proxy)."); LocalListener.End(); ProxyClient.End(); }; // route local events to the socket. ProxyClient.OnData += (data) => { notifyln(data.ToString(Encoding.ASCII)); LocalListener.Write(data); }; ProxyClient.OnError += (error) => { notifyln(String.Format("Connection to proxy server dropped:\n\r{0}\n\r", error.Message)); ProxyClient.End(); LocalListener.End(); }; ProxyClient.OnConnect += () => { notifyln(String.Format("Connection established with proxy server {0}:{1}.", strSocksIP, socksPort)); LocalListener.OnData += (data) => { ProxyClient.Write(data); }; }; }).Listen(localPort); }