Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.Azure.Management.Fluent;
- using Microsoft.Azure.Management.ResourceManager.Fluent;
- using Microsoft.Azure.Management.ResourceManager.Fluent.Authentication;
- using Microsoft.Azure.Management.ResourceManager.Fluent.Core;
- using MinecraftServerRCON;
- using System;
- using System.Collections.Generic;
- using System.Fabric;
- using System.Fabric.Health;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- namespace MainCraftFeatures
- {
- class Program
- {
- private static Uri ApplicationName = new Uri("fabric:/WordCount");
- private static string ServiceManifestName = "WordCount.Service";
- private static string NodeName = FabricRuntime.GetNodeContext().NodeName;
- private static Timer ReportTimer = new Timer(new TimerCallback(SendReport), null, 30 * 1000, 30 * 1000);
- private static FabricClient Client = new FabricClient(new FabricClientSettings() { HealthReportSendInterval = TimeSpan.FromSeconds(0) });
- static void Main(string[] args)
- {
- //var username = "hacker3@OTAPRD409ops.onmicrosoft.com";
- //var password = "{{^o5Gw>BFW6";
- ////var clientId = "da22f8cd-a867-4ccd-9cc0-d17282424979";
- //var logApi = "38371c25-3aa9-4cae-bbe2-467508e6f13c";
- //string tenantID = "cc3bc33c-7736-4cd1-80ad-438005696967";
- //var environment = AzureEnvironment.AzureUSGovernment;
- //AzureCredentials credentials =
- // SdkContext.AzureCredentialsFactory.FromUser(
- // username,
- // password,
- // logApi,
- // tenantID,
- // environment);
- //var azure =
- // Azure.Authenticate(credentials).WithDefaultSubscription();
- // var clusterAddress = "newhope.eastus.cloudapp.azure.com:19000";
- //var serverThumb = "3024A8A50F7746F3FBC647EC14B219F53D01A17A";
- //var claimsCredential = new ClaimsCredentials();
- //claimsCredential.ServerThumbprints.Add(serverThumb);
- //var fabricClient = new FabricClient(clusterAddress);
- //var services = fabricClient.QueryManager.GetServiceListAsync(new Uri("fabric:/MinecraftService")).Result;
- using (var rcon = RCONClient.INSTANCE)
- {
- rcon.setupStream(
- "ohmywpscluster.westus.cloudapp.azure.com",
- password: "cheesesteakjimmys");
- while (true)
- {
- string command = Console.ReadLine();
- string answer =
- rcon.sendMessage(
- RCONMessageType.Command,
- command);
- Console.WriteLine(answer);
- }
- }
- }
- public static void SendReport(object obj)
- {
- // Test whether the resource can be accessed from the node
- HealthState healthState = this.TestConnectivityToExternalResource();
- // Send report on deployed service package, as the connectivity is needed by the specific service manifest
- // and can be different on different nodes
- var deployedServicePackageHealthReport = new DeployedServicePackageHealthReport(
- ApplicationName,
- ServiceManifestName,
- NodeName,
- new HealthInformation("ExternalSourceWatcher", "Connectivity", healthState));
- // TODO: handle exception. Code omitted for snippet brevity.
- // Possible exceptions: FabricException with error codes
- // FabricHealthStaleReport (non-retryable, the report is already queued on the health client),
- // FabricHealthMaxReportsReached (retryable; user should retry with exponential delay until the report is accepted).
- Client.HealthManager.ReportHealth(deployedServicePackageHealthReport);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement