Beispiel #1
0
        static async Task Main(string[] args)
        {
            TrinityConfig.LoggingLevel = LogLevel.Verbose;

            m_trinity = new TrinityClient("testcluster100.southcentralus.cloudapp.azure.com:8800");

            m_trinity.Start();

            long iterations = 0;

            PingMessagePayload syncPingMessage  = new PingMessagePayload("Ping Message from External Synchronous GE Client over Native TCP. Hello GE/SF");
            PingMessagePayload asyncPingMessage = new PingMessagePayload("Ping Message from External Asynchronous GE Client over Native TCP.Hello GE/SF");


            while (true)
            {
                m_trinity?.ExternalClientPing(new PingMessagePayloadWriter(syncPingMessage.PingMessage));

                var response = await m_trinity
                               ?.ExternalClientPingAsync(new PingMessagePayloadWriter(asyncPingMessage.PingMessage));

                Console.WriteLine($"Async Response from GE/SF Graph Data Service: {response.PingMessage}");

                await Task.Delay(TimeSpan.FromSeconds(1));
            }
        }
        /// <summary>
        /// This is the main entry point for your service instance.
        /// </summary>
        /// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service instance.</param>
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            // TODO: Replace the following sample code with your own logic
            //       or remove this RunAsync override if it's not needed in your service.

            long iterations = 0;

            while (true)
            {
                cancellationToken.ThrowIfCancellationRequested();

                ServiceEventSource.Current.ServiceMessage(this.Context, "GraphEngine Remoting Client Working-{0}. Execute PING!", ++iterations);

                m_trinity?.Ping();

                using var serverHelloMessage = new PingMessagePayloadWriter(@"Hello from Server");

                m_trinity?.ExternalClientPing(serverHelloMessage);

                await Task.Delay(TimeSpan.FromSeconds(30), cancellationToken);
            }
        }