/// <summary>
        /// Reaction on something received
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <param name="args">The <see cref="aceRemoteInstanceBaseEventArgs"/> instance containing the event data.</param>
        public void received(aceRemoteInstanceBase instance, aceRemoteInstanceBaseEventArgs args)
        {
            string ip = args.socket.RemoteEndPoint.ToString();

            log("Received [" + ip.ToString() + "]: " + args.message);

            string msg = args.message.Trim();

            if (msg.Length > 4)
            {
                string cmd = msg.Substring(0, 3).ToUpper();
                string par = msg.Substring(4).Trim();

                switch (cmd)
                {
                case "RND":
                    if (string.IsNullOrWhiteSpace(par))
                    {
                        par = "5";
                    }
                    int    _rndTimes = int.Parse(par);
                    Random random    = new Random();
                    for (int ri = 0; ri < _rndTimes; ri++)
                    {
                        string rnd = imbSCI.Core.extensions.text.imbStringGenerators.getRandomString(32);     //aceCommonExtensions.getRandomString(32);

                        int rnt = random.Next(10) * 200;

                        sendStack.Enqueue(new aceRemoteSendTask(rnd, rnt, args.socket));
                    }
                    break;

                case "ECH":
                    if (string.IsNullOrWhiteSpace(par))
                    {
                        par = "[echo]";
                    }
                    sendStack.Enqueue(new aceRemoteSendTask(par, 0, args.socket));
                    break;

                case "PNG":
                    if (string.IsNullOrWhiteSpace(par))
                    {
                        par = "5";
                    }

                    int _pngTimes = int.Parse(par);
                    for (int pi = 0; pi < _pngTimes; pi++)
                    {
                        sendStack.Enqueue(new aceRemoteSendTask("ping [" + pi.ToString("D3") + "/" + _pngTimes + "]", 200, args.socket));
                    }
                    break;

                default:
                    log("Unknown command [" + msg + "]");
                    break;
                }
            }
        }
示例#2
0
 public void sending(aceRemoteInstanceBase instance, aceRemoteInstanceBaseEventArgs args)
 {
     log("-- sending[" + args.socket.RemoteEndPoint.ToString() + "] :: " + args.message);
 }