public void SendToken(string host, string connectCode) { var st = new StartToken { ConnectCode = connectCode, Host = host }; OnToken?.Invoke(this, st); }
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 OnTokenHandler(object sender, StartToken token) { if (socket.Connected) { // Disconnect from the existing host... socket.DisconnectAsync().ContinueWith((t) => { // ...then connect to the new one. this.Connect(token.Host, token.ConnectCode); }); } else { // Connect using the host and connect code specified by the token. this.Connect(token.Host, token.ConnectCode); } }
public void OnTokenHandler(object sender, StartToken token) { Settings.conInterface.WriteModuleTextColored("ClientSocket", Color.Cyan, $"Attempting to connect to host {Color.LimeGreen.ToTextColor()}{token.Host}{Color.White.ToTextColor()} with connect code {Color.Red.ToTextColor()}{token.ConnectCode}{Color.White.ToTextColor()}"); if (socket.Connected) { // Disconnect from the existing host... socket.DisconnectAsync().ContinueWith((t) => { // ...then connect to the new one. Connect(token.Host, token.ConnectCode); }); } else { // Connect using the host and connect code specified by the token. Connect(token.Host, token.ConnectCode); } }
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(); } }
protected virtual void OnTokenEvent(StartToken e) { // Safely raise the event for all subscribers OnToken?.Invoke(this, e); }
public void startWithToken(string uri) { OnToken?.Invoke(this, StartToken.FromString(uri)); }