static void test2()
        {
            Console.Write("PORT:");
            int port = int.Parse(Console.ReadLine());

            Client.Client client = new Client.Client("127.0.0.1", 9840, port);
            client.Init();
            ClientUser    c  = client.UserInfo;
            NCAsyncResult aa = (NCAsyncResult)client.BeginLogin("1501", "123", ar =>
                                                                { }
                                                                , null);

            while (!aa.IsCompleted)
            {
                Console.WriteLine("等待中。。。");
            }
            Console.WriteLine(aa.BaseResult.ToString() + aa.Info);

            client.BeginLogin("0000", "123456", ar =>
            {
                var a = (NCAsyncResult)ar;
                Console.WriteLine(a.BaseResult.ToString() + a.Info);
            }
                              , null);
            Console.Read();
        }
        static void Main(string[] args)
        {
            string path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(ProgramTesting)).CodeBase) + "\\";

            IClient client1 = new Client("test1", 4000, path, "conf/Client.xml");
            Thread t1 = new Thread(client1.Init);
            t1.Start();

            Thread.Sleep(1000);

            IClient client2 = new Client("test2", 4001, path, "conf/Client.xml");
            Thread t2 = new Thread(client2.Init);
            t2.Start();

            Thread.Sleep(1000);

            IClient client3 = new Client("test3", 4002, path, "conf/Client.xml");
            Thread t3 = new Thread(client3.Init);
            t3.Start();

            /*
            Thread.Sleep(1000);

            IClient client4 = new Client("conf/Client4.xml");
            Thread t4 = new Thread(client4.Init);
            t4.Start();

            Thread.Sleep(1000);

            IClient client5 = new Client("conf/Client5.xml");
            Thread t5 = new Thread(client5.Init);
            t5.Start();
             */
        }
Exemple #3
0
        static void Main()
        {
            Client client = new Client();
            client.Connect();

            Console.ReadKey();
        }
Exemple #4
0
 private ActionHandler(string action, string name, ParamNode[] parms, Client.Plugin plugin)
 {
     this.m_Action = action;
     this.m_Name = name;
     this.m_Params = parms;
     this.m_Plugin = plugin;
 }
        public CustomMultiEntry(int ser, int rev, Client.Multi baseMulti, int compressionType, byte[] buffer)
        {
            int num;
            int num2;
            int num3;
            int num4;
            this.m_Serial = ser;
            this.m_Revision = rev;
            baseMulti.GetBounds(out num, out num2, out num3, out num4);
            ArrayList list = new ArrayList();
            try
            {
                switch (compressionType)
                {
                    case 0:
                        LoadUncompressed(buffer, list);
                        goto Label_0060;

                    case 3:
                        break;

                    default:
                        goto Label_0060;
                }
                LoadDeflated(num, num2, num3, num4, buffer, list);
            }
            catch (Exception exception)
            {
                Debug.Error(exception);
            }
            Label_0060:
            this.m_Multi = new Client.Multi(list);
        }
Exemple #6
0
        public bool BookRoom(string token, string infos)
        {
            Partner partner = checkToken(token);

            if (partner == null)
            {
                return(false);
            }

            BookingInfos bookingInfos = JsonConvert.DeserializeObject <BookingInfos>(infos);

            Client.Client client = hotel.clients.Find(c => c.firstName.Equals(bookingInfos.firstName) && c.lastName.Equals(bookingInfos.lastName));
            if (client == null)
            {
                client = hotel.addClient(bookingInfos.firstName, bookingInfos.lastName);
            }

            Room room = hotel.rooms.Find(r => r.id.Equals(bookingInfos.roomId) && !hotel.isRoomReserved(r, bookingInfos.arrival, bookingInfos.departure));

            if (room == null)
            {
                return(false);
            }

            client.createBooking(room, bookingInfos.creditCardInfos, bookingInfos.arrival, bookingInfos.departure);
            return(true);
        }
Exemple #7
0
 public Computer(Client client)
 {
     this.compID = client.GetCompID();
     this.client = client;
     services = new List<Communication.Service>();
     scheduledTasks = new List<ScheduledTask>();
 }
Exemple #8
0
 static void Main(string[] args)
 {
     Client client = new Client();
     Console.WriteLine("Starting Engine");
     TestingConsole testingConsole = new TestingConsole(client);
     testingConsole.RunTestingEngine();
 }
 public ConnectionHandler(Client mainForm)
 {
     this.mainForm = mainForm;
     ServerSocket = new TcpClient();
     messageHandler = new MessageHandler();
     PacketManager.DefineOpcodeHandlers();
 }
 public Form2(Client form, string[] items)
 {
     InitializeComponent();
     this._form = form;
     FillBox(items);
     checkedListBox1.SelectionMode = SelectionMode.One;
     checkedListBox1.MultiColumn = false;
 }
Exemple #11
0
        static void Main(string[] args)
        {
            if (args.Length < 3) { Environment.Exit(0); }
            Client client = new Client(args[0], args[1], args[2]);

            System.Console.WriteLine("<enter> para sair...");
            System.Console.ReadLine();
        }
Exemple #12
0
        static void Main(string[] args)
        {

           Client client = new Client();
           client.Start();
           

        }
Exemple #13
0
 public CommandPrompt(Client client)
 {
     InitializeComponent();
     _client = client;
     promptBox.ReadOnly = true;
     HideCaret(promptBox.Handle);
     _communicationThread = new Thread(new ThreadStart(CommunicationThread));
     _communicationThread.Start();
 }
Exemple #14
0
        private void ProcessMessage(Client.NetMessage message)
        {
            if (message.type == Client.MessageTypes.ConnectionLost)
            {
                PrintToPrompt("Lost connection to server.");
            }

            PrintToPrompt("Server: " + message.data);
        }
Exemple #15
0
        public void InsertPart(string text, Client.ContentLine.MessageStyle InputStyle, bool WriteLog = true, long Date = 0, bool SuppressPing = false, bool IgnoreUpdate = false)
        {
            DateTime time = DateTime.Now;

            if (Date != 0)
            {
                time = DateTime.FromBinary(Date);
            }

            if (EndingLine == null)
            {
                EndingLine = new ContentLine(InputStyle, text, time, false);

                if (Thread.CurrentThread == Core._KernelThread && (!Configuration.Scrollback.DynamicReload || WindowVisible()))
                {
                    if (lastDate > time)
                    {
                        Flush();
                        SortNeeded = true;
                        Reload(true);
                    }
                    else
                    {
                        InsertPartToText(EndingLine);
                    }
                }
                else
                {
                    lock (UndrawnTextParts)
                    {
                        UndrawnTextParts.Add(new TextPart(Configuration.Scrollback.format_date.Replace("$1",
                                          time.ToString(Configuration.Scrollback.timestamp_mask)) + text, InputStyle, time));
                    }
                }
            }
            else
            {
                lock (EndingLine)
                {
                    EndingLine.text += text;
                }

                if (Thread.CurrentThread == Core._KernelThread && (!Configuration.Scrollback.DynamicReload || WindowVisible()))
                {
                    InsertPartToText(text);
                }
                else
                {
                    lock (UndrawnTextParts)
                    {
                        UndrawnTextParts.Add(new TextPart(text, InputStyle, time));
                    }
                }
            }
        }
Exemple #16
0
 public static void Main(string[] args)
 {
     var client = new Client();
     var hostIndex = Array.IndexOf(args, "--host");
     var host = hostIndex != -1 && hostIndex + 1 < args.Length
         ? args[hostIndex + 1]
         : "assaultwing.com";
     client.Start(host,
         userConfigure: args.Contains("--config"),
         debugSettings: args.Contains("--debug"));
 }
Exemple #17
0
 public GDraggedItem(Client.Item item)
     : base(0, 0)
 {
     this.m_vCache = new VertexCache();
     this.m_Item = item;
     int index = this.m_Item.ID & 0x3fff;
     int amount = (ushort) this.m_Item.Amount;
     this.m_Double = Map.m_ItemFlags[index][TileFlag.Generic] && (amount > 1);
     if ((index >= 0xeea) && (index <= 0xef2))
     {
         int num3 = (index - 0xeea) / 3;
         num3 *= 3;
         num3 += 0xeea;
         this.m_Double = false;
         if (amount <= 1)
         {
             index = num3;
         }
         else if ((amount >= 2) && (amount <= 5))
         {
             index = num3 + 1;
         }
         else
         {
             index = num3 + 2;
         }
     }
     this.m_Hue = Hues.GetItemHue(index, this.m_Item.Hue);
     this.m_Image = this.m_Hue.GetItem(index);
     if ((this.m_Image != null) && !this.m_Image.IsEmpty())
     {
         this.m_Draw = true;
         this.m_Width = this.m_Image.Width;
         this.m_Height = this.m_Image.Height;
         int num4 = this.m_Double ? 6 : 1;
         this.m_xOffset = base.m_OffsetX = this.m_Image.xMin + (((this.m_Image.xMax - this.m_Image.xMin) + num4) / 2);
         this.m_yOffset = this.m_Image.yMin;
         base.m_OffsetY = this.m_yOffset + (((this.m_Image.yMax - this.m_Image.yMin) + num4) / 2);
         if (this.m_Double)
         {
             this.m_Width += 5;
             this.m_Height += 5;
         }
     }
     base.m_DragCursor = false;
     base.m_CanDrag = true;
     base.m_QuickDrag = true;
     base.m_IsDragging = true;
     Gumps.Drag = this;
     Gumps.LastOver = this;
     base.m_X = Engine.m_xMouse - base.m_OffsetX;
     base.m_Y = Engine.m_yMouse - base.m_OffsetY;
 }
Exemple #18
0
        static void Main(string[] args)
        {
            Console.WriteLine("--------------------------");
            Console.WriteLine("Welcome to our HAL-client.");
            Console.WriteLine("Have fun!");
            Console.WriteLine("--------------------------");
            Console.WriteLine();
            Client tcpcli = new Client();
            tcpcli.Connect();

            Console.ReadLine();
        }
Exemple #19
0
 public GTextButton(string text, IFont font, IHue defaultHue, IHue focusHue, int x, int y, Client.OnClick onClick)
     : base(x, y)
 {
     this.m_CanHitTest = true;
     this.m_Hues = new IHue[] { defaultHue, focusHue };
     this.m_OnClick = onClick;
     base.m_Text = text;
     base.m_Font = font;
     base.m_Hue = defaultHue;
     base.m_ITranslucent = true;
     this.Refresh();
 }
        private void BuildClients()
        {
            var numberOfConnections = int.Parse(textBox1.Text);

            Parallel.For(0, numberOfConnections, (i) =>
            {
                var client = new Client.Client(_host, _port, log, $"{i:D4}");

                _clients.Add(client);
                client.Start();
            });
        }
 public TickEvents(Client.Client client) : base(client)
 {
     client.RegisterEventHandler("baseevents:enteredVehicle", new Action <int, int, string>((veh, seat, name) => {
         DataLoader.RemoveTickState(TickUsage.OutVehicle);
         DataLoader.AddTickState(TickUsage.InVehicle);
     }));
     client.RegisterEventHandler("baseevents:leftVehicle", new Action <int, int, string>((veh, seat, name) => {
         DataLoader.RemoveTickState(TickUsage.InVehicle);
         DataLoader.AddTickState(TickUsage.OutVehicle);
     }));
     DataLoader.AddTickState(TickUsage.OutVehicle);
     DataLoader.AddTickState(TickUsage.NotAiming);
 }
Exemple #22
0
 public BuyInfo(Client.Item item, int price, string name)
 {
     this.m_Item = item;
     this.m_Price = price;
     try
     {
         this.m_Name = Localization.GetString(Convert.ToInt32(name));
     }
     catch
     {
         this.m_Name = name;
     }
 }
 private void Client_button_connect_Click(object sender, EventArgs e)
 {
     //创建新客户端socket连接
     try
     {
         clientEnd = new Client.Client(IPAddress.Parse(client_ip.Text), Convert.ToInt32(client_port.Text));
         clientEnd.Connect();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemple #24
0
        public Tags(Client client)
        {
            this.client = client;
            InitializeComponent();

            //Add in all tags
            var items = listBox1.Items;
            List<String> temp = client.getListOfAllTags();

            foreach (String x in temp)
            {
                items.Add(x);
            }
        }
Exemple #25
0
 public static void Mainq()
 {
     Client client = new Client();
     while (!client.Connected)
     {
         Console.Write("Server IP Adress : ");
         string ip = Console.ReadLine();
         Console.Write("Port : ");
         int port = Convert.ToInt32(Console.ReadLine());
         Console.Write("Enter your name : ");
         client.Connect(ip, port, Console.ReadLine());
         Console.WriteLine();
     }
     client.Run();
 }
Exemple #26
0
        /// <summary>
        /// Change the color of text
        /// </summary>
        /// <param name="text"></param>
        /// <param name="SBAB"></param>
        /// <returns></returns>
        public static Client.RichTBox.ContentText color(string text, Client.RichTBox SBAB)
        {
            if (text.Contains(colorchar.ToString()))
            {
                int color = 0;
                bool closed = false;
                int position = 0;
                while (text.Length > position)
                {
                    if (text[position] == colorchar)
                    {
                        if (closed)
                        {
                            text = text.Substring(position, text.Length - position);
                            Client.RichTBox.ContentText Link = new Client.RichTBox.ContentText(ProtocolIrc.DecodeText(text), Configuration.CurrentSkin.mrcl[color]);
                            return Link;
                        }

                        if (!closed)
                        {
                            if (!int.TryParse(text[position + 1].ToString() + text[position + 2].ToString(), out color))
                            {
                                if (!int.TryParse(text[position + 1].ToString(), out color))
                                {
                                    color = 0;
                                }
                            }
                            if (color > 9)
                            {
                                text = text.Remove(position, 3);
                            }
                            else
                            {
                                text = text.Remove(position, 2);
                            }
                            closed = true;
                            if (color < 16)
                            {
                                text = text.Substring(position);
                                break;
                            }
                        }
                    }
                    position++;
                }
            }
            return null;
        }
Exemple #27
0
 public GParamMenu(ParamNode param, ActionHandler handler, Client.Action action)
     : base(param.Name)
 {
     this.m_Param = param;
     this.m_Handler = handler;
     this.m_Action = action;
     if (this.m_Action == null)
     {
         base.Tooltip = new Tooltip(string.Format("Click here to add the instruction:\n{0} {1}", handler.Name, param.Name), true);
     }
     else
     {
         base.Tooltip = new Tooltip("Click here to change the parameter", true);
     }
     base.Tooltip.Delay = 3f;
 }
Exemple #28
0
 static void Main(string[] arguments)
 {
     ClientConfiguration configuration;
     try
     {
         Serialiser<ClientConfiguration> serialiser = new Serialiser<ClientConfiguration>("Configuration.xml");
         configuration = serialiser.Load();
     }
     catch (Exception exception)
     {
         Console.WriteLine("Configuration error: {0}", exception.Message);
         return;
     }
     Client client = new Client(configuration);
     client.Run();
 }
Exemple #29
0
 public GContainerItem(Client.Item Item, Client.Item Container)
     : base(Item.ContainerX, Item.ContainerY)
 {
     this.m_Item = Item;
     this.m_Container = Container;
     this.m_TileID = this.m_Item.ID;
     this.m_Hue = Hues.GetItemHue(this.m_TileID, this.m_Item.Hue);
     this.State = 0;
     base.m_CanDrag = true;
     base.m_CanDrop = true;
     base.m_QuickDrag = false;
     base.m_DragCursor = false;
     if (Engine.Features.AOS)
     {
         base.Tooltip = new ItemTooltip(this.m_Item);
     }
 }
Exemple #30
0
        private Program()
        {
            Console.WriteLine("++++++++++++++++++++++");

            client = new Client.Client("../../config/ClientConfig.txt", new ReceiverImpl(), "QQ");

            client.connectToServer();

            Console.ReadLine();

            client.send(Encoding.UTF8.GetBytes("GG"));

            Console.WriteLine("++++++++++++++++++++++");

            Console.ReadLine();

            client.disconnect();
        }
Exemple #31
0
 /// <summary>
 /// Write message to a file
 /// </summary>
 /// <param name="text"></param>
 /// <param name="InputStyle"></param>
 /// <param name="owner"></param>
 /// <param name="directory"></param>
 /// <param name="time"></param>
 public static void Log(string text, Client.ContentLine.MessageStyle InputStyle, Graphics.Window owner, string directory, DateTime time)
 {
     try
     {
         if (!Directory.Exists(Configuration.Logs.logs_dir))
         {
             Directory.CreateDirectory(Configuration.Logs.logs_dir);
         }
         if (!Directory.Exists(Configuration.Logs.logs_dir + Path.DirectorySeparatorChar + owner._Network.ServerName))
         {
             System.IO.Directory.CreateDirectory(Configuration.Logs.logs_dir + Path.DirectorySeparatorChar + owner._Network.ServerName);
         }
         if (!Directory.Exists(Configuration.Logs.logs_dir + Path.DirectorySeparatorChar + owner._Network.ServerName + Path.DirectorySeparatorChar + validpath(owner, directory)))
         {
             Directory.CreateDirectory(Configuration.Logs.logs_dir + Path.DirectorySeparatorChar + owner._Network.ServerName + Path.DirectorySeparatorChar + validpath(owner, directory));
         }
         if (Configuration.Logs.logs_txt)
         {
             string stamp = "";
             if (Configuration.Scrollback.chat_timestamp)
             {
                 stamp = Configuration.Scrollback.format_date.Replace("$1", time.ToString(Configuration.Scrollback.timestamp_mask));
             }
             Core.IO.InsertText(stamp + Protocol.DecodeText(Core.RemoveSpecial(text)) + "\n", _getFileName(owner, directory, time) + ".txt");
         }
         if (Configuration.Logs.logs_html)
         {
             string stamp = "";
             if (Configuration.Scrollback.chat_timestamp)
             {
                 stamp = Configuration.Scrollback.format_date.Replace("$1", time.ToString(Configuration.Scrollback.timestamp_mask));
             }
             Core.IO.InsertText("<font size=\"" + Configuration.CurrentSkin.FontSize.ToString() + "px\" face=" + Configuration.CurrentSkin.LocalFont + ">" + System.Web.HttpUtility.HtmlEncode(stamp + Protocol.DecodeText(Core.RemoveSpecial(text))) + "</font><br>\n", _getFileName(owner, directory, time) + ".html");
         }
         if (Configuration.Logs.logs_xml)
         {
             Core.IO.InsertText("<line time=\"" + time.ToBinary().ToString() + "\" style=\"" + InputStyle.ToString() + "\">" + System.Web.HttpUtility.HtmlEncode(Protocol.DecodeText(Core.RemoveSpecial(text))) + "</line>\n", _getFileName(owner, directory, time) + ".xml");
         }
     }
     catch (Exception fail)
     {
         Core.handleException(fail);
     }
 }
Exemple #32
0
 static void Main(string[] args)
 {
     var client = new Client();
     Console.WriteLine("Wpisz co chcesz przesłać na serwer a następnei wciśnij ENTER (jeśli chcesz zakończyć wpisz tylko EXIT):");
     string buffor = null;
     client.Start();
     while (true)
     {
         Console.Write("[CLIENT]: ");
         buffor = Console.ReadLine();
         client.SendMessage(buffor);
         if (buffor.ToUpper().Equals("EXIT"))
         {
             break;
         }
     }
     client.Stop();
     Console.ReadKey();
 }
Exemple #33
0
        static void Main(string[] args)
        {
            string username = args[0];
            int port = Convert.ToInt32(args[1]);
            string path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Program)).CodeBase)+"\\";
            Console.WriteLine(username+" "+port);

            IClient client = new Client(username, port, path, "conf/Client.xml");
            Thread thread = new Thread(client.Init);
            thread.Start();

            /*

            IClient client1 = new Client("conf/Client1.xml");
            Thread t1 = new Thread(client1.Init);
            t1.Start();

            Thread.Sleep(1000);

            IClient client2 = new Client("conf/Client2.xml");
            Thread t2 = new Thread(client2.Init);
            t2.Start();

            Thread.Sleep(1000);

            IClient client3 = new Client("conf/Client3.xml");
            Thread t3 = new Thread(client3.Init);
            t3.Start();

            Thread.Sleep(1000);

            IClient client4 = new Client("conf/Client4.xml");
            Thread t4 = new Thread(client4.Init);
            t4.Start();

            Thread.Sleep(1000);

            IClient client5 = new Client("conf/Client5.xml");
            Thread t5 = new Thread(client5.Init);
            t5.Start();
             */
        }
Exemple #34
0
 public SellInfo(Client.Item item, int itemID, int hue, int amount, int price, string name)
 {
     this.m_Item = item;
     this.m_ItemID = itemID;
     this.m_Amount = amount;
     this.m_Price = price;
     try
     {
         this.m_Name = Localization.GetString(Convert.ToInt32(name));
     }
     catch
     {
         this.m_Name = name;
     }
     if (!Map.m_ItemFlags[itemID & 0x3fff][TileFlag.PartialHue])
     {
         hue ^= 0x8000;
     }
     this.m_Hue = Hues.Load(hue);
 }
Exemple #35
0
 public GContainer(Client.Item container, int gumpID, IHue hue)
     : base(0.25f, 0.25f, 0.6f, gumpID, 50, 50, hue)
 {
     this.m_HitTest = true;
     this.m_Hash = new Hashtable();
     this.m_Item = container;
     base.m_CanDrop = true;
     this.GetBounds(gumpID);
     base.m_NonRestrictivePicking = true;
     ArrayList items = container.Items;
     int count = items.Count;
     for (int i = 0; i < count; i++)
     {
         Client.Item item = (Client.Item) items[i];
         if (((base.m_GumpID != 9) || ((item.ID & 0x3fff) < 0x2006)) || ((item.ID & 0x3fff) > 0x2050))
         {
             Client.Gump toAdd = new GContainerItem(item, this.m_Item);
             this.m_Hash[item] = toAdd;
             toAdd.m_CanDrag = !this.m_TradeContainer;
             base.m_Children.Add(toAdd);
         }
     }
 }
Exemple #36
0
 public GDragAmount(Client.Item item)
     : base(0x85c, 0, 0)
 {
     GTextBox box;
     this.m_First = true;
     this.m_Item = item;
     int amount = (ushort) this.m_Item.Amount;
     this.m_Amount = amount;
     this.m_Okay = new GButtonNew(0x81a, 0x81c, 0x81b, 0x66, 0x25);
     this.m_Okay.CanEnter = true;
     this.m_Okay.Clicked += new EventHandler(this.Okay_Clicked);
     base.m_Children.Add(this.m_Okay);
     GSlider toAdd = new GSlider(0x845, 0x23, 0x10, 0x5f, 15, (double) amount, 0.0, (double) amount, 1.0) {
         OnValueChange = new OnValueChange(this.Slider_OnValueChange)
     };
     base.m_Children.Add(toAdd);
     this.m_Slider = toAdd;
     GHotspot hotspot = new GHotspot(0x1c, 0x10, 0x6d, 15, toAdd);
     base.m_Children.Add(hotspot);
     box = new GTextBox(0, false, 0x1a, 0x2b, 0x42, 15, amount.ToString(), Engine.GetFont(1), Hues.Load(0x455), Hues.Load(0x455), Hues.Load(0x455)) {
         OnTextChange = (OnTextChange) Delegate.Combine(box.OnTextChange, new OnTextChange(this.TextBox_OnTextChange)),
         OnBeforeTextChange = (OnBeforeTextChange) Delegate.Combine(box.OnBeforeTextChange, new OnBeforeTextChange(this.TextBox_OnBeforeTextChange)),
         EnterButton = this.m_Okay
     };
     base.m_Children.Add(box);
     this.m_TextBox = box;
     box.Focus();
     base.m_IsDragging = true;
     base.m_OffsetX = this.Width / 2;
     base.m_OffsetY = this.Height / 2;
     Gumps.LastOver = this;
     Gumps.Drag = this;
     Gumps.Focus = this;
     base.m_X = Engine.m_xMouse - base.m_OffsetX;
     base.m_Y = Engine.m_yMouse - base.m_OffsetY;
 }
Exemple #37
0
        static void Main(string[] args)
        {
            Client client = new Client("127.0.0.1", 9999);

            Parallel.Invoke(client.Send, client.Recieve);
        }
Exemple #38
0
        public static void Main(string[] args)
        {
            TcpListener server = null;

            try
            {
                // Set the TcpListener on port 13000.
                Int32     port      = 13000;
                IPAddress localAddr = IPAddress.Parse("127.0.0.1");

                // TcpListener server = new TcpListener(port);
                server = new TcpListener(localAddr, port);

                // Start listening for client requests.
                server.Start();

                // Buffer for reading data
                Byte[] bytes = new Byte[256];
                String data  = null;

                //Create client and run async
                //I wonder if it will work....
                Client.Client messagingClient = new Client.Client(port, localAddr.ToString());
                Action        clientAction    = messagingClient.clientMain;
                clientAction.BeginInvoke(ar => clientAction.EndInvoke(ar), null);


                // Enter the listening loop.
                while (true)
                {
                    Console.Write("[SERVER]Waiting for a connection... ");

                    // Perform a blocking call to accept requests.
                    // You could also user server.AcceptSocket() here.
                    TcpClient client = server.AcceptTcpClient();
                    Console.WriteLine("[SERVER]Connected!");

                    data = null;

                    // Get a stream object for reading and writing
                    NetworkStream stream = client.GetStream();

                    int i;

                    // Loop to receive all the data sent by the client.
                    while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
                    {
                        // Translate data bytes to a ASCII string.
                        data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
                        Console.WriteLine("[SERVER]Received: {0}", data);

                        // Process the data sent by the client.
                        data = data.ToUpper();

                        byte[] msg = System.Text.Encoding.ASCII.GetBytes(Console.ReadLine());

                        // Send back a response.
                        stream.Write(msg, 0, msg.Length);
                        Console.WriteLine("[SERVER]Sent: {0}", data);
                    }

                    // Shutdown and end connection
                    client.Close();
                }
            }
            catch (SocketException e)
            {
                Console.WriteLine("[SERVER]SocketException: {0}", e);
            }
            finally
            {
                // Stop listening for new clients.
                server.Stop();
            }


            Console.WriteLine("\n[SERVER]Hit enter to continue...");
            Console.Read();
        }
Exemple #39
0
        static void Main(string[] args)
        {
            TestExecutive testExecutive = new TestExecutive();

            Client.Client             client       = new Client.Client();
            buildRequest.buildRequest buildRequest = new buildRequest.buildRequest();

            RepoMock      repoMock    = new RepoMock();
            buildServer   buildServer = new buildServer();
            List <string> list;
            TestRequest   TestRequest = new TestRequest();
            TestHarness   TestHarness = new TestHarness();
            Dictionary <string, string> dictionary;


            Console.WriteLine("\n\n-------------------------Project 2: Demosntrating a Build Server------------------------------------- \n\n");
            Console.WriteLine("***********************************************************************************************************\n\n");

            //-------------------------------------------<Requirment 1>---------------------------------------------------------------------------------
            Console.WriteLine("\n\tRequirment 1: \n\n");
            Console.WriteLine("=========================================================================\n");
            Console.WriteLine("\t\tProject Prepared using C# .Net Framework and Visual Studio 2017" + Environment.Version.ToString() + "\n\n");
            Console.WriteLine("-----------------------------------------------------------------------------------\n\n");

            //----------------------------------------------<Requirment 2>------------------------------------------------------------------------------
            Console.WriteLine("\n\t Requirment 2: \n\n");
            Console.WriteLine("=========================================================================\n");
            Console.WriteLine("\t\tInclude a package for\n" + nameof(buildRequest) + "\n\n" + nameof(client) + "\n\n" + nameof(repoMock) + "\n\n" + nameof(buildServer) + "\n\n" + nameof(TestRequest) + "\n\n" + nameof(TestHarness) + "\n\n" + nameof(testExecutive) + "\n\n");
            Console.WriteLine("------------------------------------------------------------------------------------------------------------------------\n\n\n");

            //------------------------------------------------<Requirment 3>----------------------------------------------------------------------------------
            Console.WriteLine("\n\n\t Requirment 3: \n");
            Console.WriteLine("=========================================================================\n");
            Console.WriteLine("\t\tConstructed a fixed sequence of operations of the mock repository, mock test harness, and core builder\n\n");

            Console.WriteLine("------------------------------------------------------------------------------------------------------------------------\n\n\n");
            Console.WriteLine("The BuiltRequest Data structure generated by the client is \n");
            buildRequest = client.buildrequest();

            string sendXml = client.Xml;

            repoMock.getFiles("*.*");
            repoMock.parseRequest(buildRequest, repoMock.files);
            Console.WriteLine("\nBuiltRequest Sent to MockRepository");

            string buildrequestLocation = "../../../repoMock/repoStorage/buildRequest/buildRequest.xml";

            repoMock.savecontent(buildrequestLocation, sendXml);
            Console.WriteLine("\n\n Demonstrated the requirment of the builddriver xmlfile being saved in the repository\n\n");

            Console.WriteLine("------------------------------------------------------------------------------------------------------------------------\n\n\n");

            //----------------------------------------------<Requirment 4>------------------------------------------------------------------------------------------

            Console.WriteLine("\n\n\t Requirmrnt 4: \n");
            Console.WriteLine("=========================================================================\n");
            Console.WriteLine("\t\tRepopsitory on demand copies a set of test source files, test drivers and test request with a test for each test driver\n\n");
            Console.WriteLine("Enter command for copying a set of test source files, test drivers and test request( Enter :send)");
            string command = Console.ReadLine();

            repoMock.sendFile(command, buildrequestLocation, "../../../buildServer/builderStorage");
            Console.WriteLine("\n\nThe Demonstrated the requirment of sending the builtRequest on command to the buildserver build storage  \n");
            Console.WriteLine("-----------------------------------------------------------------------------");
            dictionary = buildServer.processBuild("../../../buildServer/builderStorage/buildRequest.xml", repoMock);
            Console.WriteLine("------------------------------------------------------------------------------------------------------------------------\n\n\n");

            //--------------------------------------------<Requirment 5>--------------------------------------------------------------------------------------------
            Console.WriteLine("\n\n\t Requirment 5:\n");
            Console.WriteLine("=========================================================================\n");
            Console.WriteLine("\t\t The build server builds each visual studio project delivered by the mock repository\n\n");
            list = buildServer.getBuilderFiles();
            list = buildServer.processdirectory(list);
            buildServer.buildFile(list, dictionary);
            Console.WriteLine("\n\nDemonstarted the requirment of successfully building the test files which have been sent to the build server repository\n\n");
            Console.WriteLine("-----------------------------------------------------------------------------------------------------------------------------\n\n");
            Console.WriteLine("------------------------------------------------------------------------------------------------------------------------\n\n\n");



            //----------------------------------------------<Requirment 6>-----------------------------------------------------------------------------------------
            Console.WriteLine("\n\n\t Requirment 6: \n");
            Console.WriteLine("=========================================================================\n");

            Console.WriteLine("\t\t The builder reported to the console the success or the failure of the build, and any warning emitted\n\n");
            Console.WriteLine("------------------------------------------------------------------------------------------------------------------------\n\n\n");



            //----------------------------------------------<Requirment 7>------------------------------------------------------------------------------------------
            Console.WriteLine("\n\n\t Requirment 7: \n");
            Console.WriteLine("=========================================================================\n");
            Console.WriteLine("\t\t The Builder on success delivered the built library path known by mock test harness \n\n ");
            TestRequest = buildServer.generateTestRequest();

            string xml = buildServer.xml;

            repoMock.getFiles("*.*");
            //     buildServer.parseTestRequest(TestRequest,buildServer.files);
            //buildServer.parseTestRequest(TestRequest, buildServer.files);
            string testRequestLocation = "../../../BuildServer/BuilderStorage/TestRequest.xml";

            repoMock.sendFile("send", testRequestLocation, "../../../DllLoaderDemo/testHarnessStorage");

            Console.WriteLine("Demonstarted the requirment of saving the testRequest in the build server");

            Console.WriteLine("------------------------------------------------------------------------------------------------------------------------\n\n\n");

            //-----------------------------------------------<Requirment 8>-------------------------------------------------------------------------------------------
            Console.WriteLine("\n\n\t Requirment 8: \n");
            Console.WriteLine("=========================================================================\n");
            Console.WriteLine("\t\t The test harness attempt to load and execute each test library \n\n");
            repoMock.savecontent(testRequestLocation, xml);
            // repoMock.sendFile("sendFile", testRequestLocation, "../../../DllLoaderDemo/testHarnessStorage");
            Console.WriteLine("Demonstrated the requirment of sending the testDriver to the testHarness");
            TestHarness.processTestRequest("../../../DllLoaderDemo/testHarnessStorage/TestRequest.xml", buildServer);
            Console.WriteLine("------------------------------------------------------------------------------------------------------------------------\n\n\n");
            Console.Write("\n\n The test driver and the test file dll have been successfully sent to the test harness\n\n");
            Console.WriteLine("-----------------------------------------------------------------------------------------\n");
            //string loadandexecute = TestHarness.loadAndExerciseTesters();

            //------------------------<For loading and executing the test libraries absolute path is required>------------------------------

            TestHarness.testersLocation = Path.GetFullPath("../../../DllLoaderDemo/testHarnessStorage");
            Console.Write("\n  Loading Test Modules from:\n    {0}\n", TestHarness.testersLocation);

            // run load and tests

            string result = TestHarness.loadAndExerciseTesters();

            Console.Write("\n\n  {0}", result);
            Console.Write("\n\n");
            Console.WriteLine("\n\nDemonstrated the requirment of Simulated testing\n\n ");
            Console.WriteLine("--------------------------------------------------------------------------------------------------------\n\n");
            Console.WriteLine("\n\n=======================================================================================================================\n\n");
        }
Exemple #40
0
 public void sqlSetUp()
 {
     client = new Client.Client();
     client.connect();
 }
Exemple #41
0
        public static void Main(string[] args)
        {
            var client = new Client.Client();

            Console.WriteLine(client.ClientRegister("127.0.0.1"));
        }
Exemple #42
0
        static void Main(string[] args)
        {
            Console.ResetColor();
            Console.WindowWidth  = 85;
            Console.WindowHeight = 31;
            Console.BufferWidth  = 85;
            Console.BufferHeight = 31;

            Console.Write("Введите имя пользователя: ");
            Console.CursorTop  = 2;
            Console.CursorLeft = 0;
            Console.WriteLine("ArrowUp/ArrowDown - выбор собеседника");
            Console.WriteLine("Enter - открыть чат/отправить сообщение");
            Console.WriteLine("Escape - вернуться к выбору собеседника");
            Console.WriteLine("Ctrl+C/Ctrl+Break - выйти из чата и закрыть программу");

            Console.CursorTop  = 0;
            Console.CursorLeft = 26;
            string username;
            bool   b;

            do
            {
                b        = true;
                username = Console.ReadLine();
                if (username.Length < 10)
                {
                    int i = 0;
                    for (; i < username.Length; i++)
                    {
                        if (!char.IsLetterOrDigit(username[i]))
                        {
                            break;
                        }
                    }

                    if (i == username.Length)
                    {
                        b = false;
                    }
                }

                client = new Client(username);
                b      = !client.Connect();

                if (b)
                {
                    Console.Write("Введите допустимое имя пользователя");
                    Console.CursorTop  = 0;
                    Console.CursorLeft = 26;
                    Console.Write(new string(' ', username.Length));
                    Console.CursorLeft = 26;
                }
            } while (b);

            Console.Title = "В системе как " + username;
            Console.Clear();
            Console.CursorVisible = false;

            Console.CancelKeyPress += (s, e) =>
            {
                client.SendDisconnect();
                Environment.Exit(0);
            };
            BuildFrame();
            Console.CursorTop  = 1;
            Console.CursorLeft = 1;
            Client_UsersRefresh(client.SendRequest());
            client.UsersRefresh    += Client_UsersRefresh;
            client.MessageReceived += Client_MessageReceived;
            while (true)
            {
                ConsoleKeyInfo key = Console.ReadKey(true);
                while (busy)
                {
                    ;
                }
                busy = true;
                switch (key.Key)
                {
                case ConsoleKey.UpArrow:
                    if (!typingMessage)
                    {
                        Console.BackgroundColor = ConsoleColor.Black;
                        Console.ForegroundColor = newMessage[selectedUser] ? ConsoleColor.Cyan : ConsoleColor.White;
                        Console.Write(users[selectedUser].PadRight(15));

                        if (--selectedUser < 0)
                        {
                            selectedUser = users.Length - 1;
                        }

                        Console.CursorTop       = 1 + selectedUser;
                        Console.CursorLeft      = 1;
                        Console.BackgroundColor = ConsoleColor.White;
                        Console.ForegroundColor = ConsoleColor.Black;
                        Console.Write(users[selectedUser].PadRight(15));
                        Console.CursorLeft = 1;
                    }
                    break;

                case ConsoleKey.DownArrow:
                    if (!typingMessage)
                    {
                        Console.BackgroundColor = ConsoleColor.Black;
                        Console.ForegroundColor = newMessage[selectedUser] ? ConsoleColor.Cyan : ConsoleColor.White;
                        Console.Write(users[selectedUser].PadRight(15));

                        if (++selectedUser >= users.Length)
                        {
                            selectedUser = 0;
                        }

                        Console.CursorTop       = 1 + selectedUser;
                        Console.CursorLeft      = 1;
                        Console.BackgroundColor = ConsoleColor.White;
                        Console.ForegroundColor = ConsoleColor.Black;
                        Console.Write(users[selectedUser].PadRight(15));
                        Console.CursorLeft = 1;
                    }
                    break;

                case ConsoleKey.LeftArrow:
                    if (!typingMessage)
                    {
                        break;
                    }

                    if (--indexMessage < 0)
                    {
                        indexMessage       = 0;
                        Console.CursorLeft = 17;
                        Console.CursorTop  = 24;
                    }
                    else
                    {
                        Console.CursorLeft--;
                    }
                    break;

                case ConsoleKey.RightArrow:
                    if (!typingMessage)
                    {
                        break;
                    }

                    if (++indexMessage > currentMessage.Length)
                    {
                        indexMessage       = currentMessage.Length;
                        Console.CursorLeft = 17 + currentMessage.Length % 67;
                        Console.CursorTop  = 24 + currentMessage.Length / 67;
                    }
                    else
                    {
                        Console.CursorLeft++;
                    }
                    break;

                case ConsoleKey.Enter:
                    if (!typingMessage)
                    {
                        Console.ResetColor();
                        newMessage[selectedUser] = false;
                        WriteChat();
                        typingMessage         = true;
                        indexMessage          = 0;
                        Console.CursorVisible = true;
                        Console.CursorLeft    = 17;
                        Console.CursorTop     = 24;
                        currentMessage        = new StringBuilder();
                    }
                    else
                    {
                        ClearMessageBox();
                        ClearDialogBox();

                        string[] strs = new string[(int)Math.Ceiling(currentMessage.Length / 67.0)];
                        int      i    = 0;
                        for (; i * 67 < currentMessage.Length && (i + 1) * 67 < currentMessage.Length; i++)
                        {
                            strs[i] = currentMessage.ToString().Substring(i * 67, 67);
                        }
                        strs[i * 67] = currentMessage.ToString().Substring(i);

                        if (!chats.ContainsKey(users[selectedUser]))
                        {
                            chats.Add(users[selectedUser], new List <string>());
                        }
                        chats[users[selectedUser]].Add($"[{username}]:{Environment.NewLine}{string.Join(Environment.NewLine, strs)}");
                        client.SendMessage(users[selectedUser], currentMessage.ToString());
                        WriteChat();

                        Console.CursorLeft = 17;
                        Console.CursorTop  = 24;
                        indexMessage       = 0;
                        currentMessage     = new StringBuilder();
                    }
                    break;

                case ConsoleKey.Escape:
                    if (typingMessage)
                    {
                        ClearMessageBox();
                        ClearDialogBox();
                        typingMessage         = false;
                        Console.CursorVisible = false;
                        Console.CursorLeft    = 1;
                        Console.CursorTop     = 1 + selectedUser;
                    }
                    break;

                default:
                    if (typingMessage)
                    {
                        Console.CursorVisible = false;
                        if (key.Key == ConsoleKey.Backspace)
                        {
                            if (indexMessage > 0)
                            {
                                currentMessage.Remove(--indexMessage, 1);
                            }
                        }
                        else if (key.Key == ConsoleKey.Delete)
                        {
                            if (indexMessage < currentMessage.Length)
                            {
                                currentMessage.Remove(indexMessage, 1);
                            }
                        }
                        else if (currentMessage.Length < 300)
                        {
                            currentMessage.Insert(indexMessage++, key.KeyChar);
                        }
                        else
                        {
                            break;
                        }

                        ClearMessageBox();
                        Console.CursorLeft = 17;
                        Console.CursorTop  = 24;
                        int i = 0;
                        for (; i < currentMessage.Length && i + 67 < currentMessage.Length; i += 67)
                        {
                            Console.Write(currentMessage.ToString().Substring(i, 67));
                            Console.CursorLeft = 17;
                            Console.CursorTop++;
                        }
                        Console.Write(currentMessage.ToString().Substring(i));

                        Console.CursorLeft    = 17 + indexMessage % 67;
                        Console.CursorTop     = 24 + indexMessage / 67;
                        Console.CursorVisible = true;
                    }
                    break;
                }
                busy = false;
            }
        }