public void RegisterMinion() { var rpcMinion = new RpcBuffer(appName, (msgId, payload) => { var serverResponse = "Carbon has a huge pp also this is debug messages."; var gotData = Encoding.UTF8.GetString(payload, 0, payload.Length); Console.WriteLine($"RPCMinion: Got data: {gotData}"); OnToken?.Invoke(this, StartToken.FromString(gotData)); //Invoke method and return. return(Encoding.UTF8.GetBytes(serverResponse)); }); }
public void RunLoop(string initialURI) { if (initialURI != null) { OnToken?.Invoke(this, StartToken.FromString(initialURI)); } while (true) { PipeSecurity ps = new PipeSecurity(); ps.AddAccessRule(new PipeAccessRule("Users", PipeAccessRights.FullControl, System.Security.AccessControl.AccessControlType.Allow)); NamedPipeServerStream pipeServer = NamedPipeServerStreamConstructors.New("AmongUsCapturePipe", PipeDirection.InOut, 1, pipeSecurity: ps); pipeServer.WaitForConnection(); Console.WriteLine("Client connected"); try { //Read the request from the client. Once the client has // written to the pipe its security token will be available. StreamString ss = new StreamString(pipeServer); string rawToken = ss.ReadString(); StartToken startToken = StartToken.FromString(rawToken); Console.WriteLine($@"Decoded message as {JsonConvert.SerializeObject(startToken, Formatting.Indented)}"); OnToken?.Invoke(this, startToken); } // Catch the IOException that is raised if the pipe is broken // or disconnected. catch (IOException e) { Console.WriteLine(@"ERROR: {0}", e.Message); } pipeServer.Close(); } }
public void startWithToken(string uri) { OnToken?.Invoke(this, StartToken.FromString(uri)); }