示例#1
0
        public void SendToken(string host, string connectCode)
        {
            var st = new StartToken {
                ConnectCode = connectCode, Host = host
            };

            OnToken?.Invoke(this, st);
        }
示例#2
0
 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));
     });
 }
示例#3
0
 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);
     }
 }
示例#4
0
 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);
     }
 }
示例#5
0
        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();
            }
        }
示例#6
0
 protected virtual void OnTokenEvent(StartToken e)
 {
     // Safely raise the event for all subscribers
     OnToken?.Invoke(this, e);
 }
示例#7
0
 public void startWithToken(string uri)
 {
     OnToken?.Invoke(this, StartToken.FromString(uri));
 }