In() public static method

public static In ( string message, bool control = false ) : bool
message string
control bool
return bool
Ejemplo n.º 1
0
 public static void Init()
 {
     while (true)
     {
         try
         {
             if (IsConnectedOnRemote)
             {
                 while (!remote_reader.EndOfStream)
                 {
                     string text = remote_reader.ReadLine();
                     Ping = DateTime.Now;
                     Buffer.In(text);
                     Thread.Sleep(20);
                 }
                 SendDisconnectOnRemote();
             }
             Thread.Sleep(20);
         }
         catch (IOException)
         {
             SendDisconnectOnRemote();
         }
         Thread.Sleep(10);
     }
 }
Ejemplo n.º 2
0
        public static void Listen()
        {
            TcpListener cache = new TcpListener(IPAddress.Parse("127.0.0.1"), port);

            cache.Start();
            Syslog.Log("Bouncer is listening on port " + port);
            Ping = DateTime.Now;
            while (true)
            {
                client = cache.AcceptTcpClient();
                NetworkStream temp = client.GetStream();
                local_writer = new StreamWriter(temp);
                local_reader = new StreamReader(temp, Encoding.UTF8);
                Syslog.Log("New client has connected to bouncer");
                try
                {
                    while (!local_reader.EndOfStream)
                    {
                        string data = local_reader.ReadLine();
                        if (string.IsNullOrEmpty(data))
                        {
                            continue;
                        }
                        if (data[0] != 'C' || !data.StartsWith("CONTROL: "))
                        {
                            Buffer.Out(data);
                        }
                        else
                        {
                            string code      = data.Replace("\r", "").Substring("CONTROLxx".Length);
                            string parameter = "";
                            if (code.Contains(" "))
                            {
                                int sidx = code.IndexOf(" ");
                                parameter = code.Substring(sidx + 1);
                                code      = code.Substring(0, sidx);
                            }
                            switch (code)
                            {
                            case "STATUS":
                                if (IsConnectedOnRemote)
                                {
                                    Buffer.In("CONTROL: TRUE", true);
                                }
                                else
                                {
                                    Buffer.In("CONTROL: FALSE", true);
                                }
                                break;

                            case "CONNECT":
                            case "CREATE":
                                Syslog.Log("Connecting to remote server: " + parameter);
                                StartIRC(parameter);
                                break;

                            case "DISCONNECT":
                                Disconnect();
                                SendDisconnectOnRemote();
                                break;
                            }
                        }
                        Thread.Sleep(20);
                    }
                    Syslog.Log("Client has disconnect on EOF");
                }
                catch (IOException)
                {
                    Syslog.Log("Client has disconnected on IOEX term");
                }
                Thread.Sleep(20);
            }
        }
Ejemplo n.º 3
0
 private static void SendDisconnectOnRemote()
 {
     Buffer.In("CONTROL: DC");
     IsConnectedOnRemote = false;
 }