Пример #1
0
        public MainForm()
        {
            InitializeComponent();

            this.timer1.Interval = 100;

            client1 = new SocketClient("127.1.1.1", 911, Program.ErrorLog, Program.DebugLog);
            client2 = new SocketClient("127.1.1.1", 911, Program.ErrorLog, Program.DebugLog);

            client1.SetValue("Testing", AssemblyInfo.Version, true);

            this.timer1.Enabled = true;

            this.socketMemCacheList1.Client = client1;
        }
Пример #2
0
 private void ServiceListener()
 {
     lock (this.listener)
     {
         if (this.listener.Pending())
         {
             var client = new SocketClient(this, this.listener.AcceptTcpClient(), ++this.lastClientID, this.ErrorLog, this.DebugLog);
             this.clients.Add(client);
             this.OnNewClient(client);
         }
     }
 }
Пример #3
0
        private void OnNewClient(SocketClient client)
        {
            try
            {
                this.Set("Host.Clients", this.clients.Count.ToString());

                if (NewClient != null)
                {
                    NewClient(client, new System.EventArgs());
                }
            }
            catch (Exception)
            {
            }
        }
Пример #4
0
        private void OnClientLost(SocketClient client)
        {
            try
            {
                this.Set("Host.Clients", this.clients.Count.ToString());

                if (ClientLost != null)
                {
                    ClientLost(client, new System.EventArgs());
                }
            }
            catch
            {
            }
        }
Пример #5
0
        internal void ProcessMessage(SocketClient client, SocketMessage message)
        {
            if (message != null)
            {
                switch (message.Command.ToLower())
                {
                    case "set":
                        this.Store(message);

                        if (message.ToID == -1)
                        {
                            this.Broadcast(message);
                        }

                        break;

                    case "get":
                        lock (this.memCache)
                        {
                            client.SendValue(this.Get(message.Member), -1);
                        }

                        break;

                    case "get-all":
                        lock (this.memCache)
                        {
                            foreach (KeyValuePair<string, SocketValue> entry in this.memCache)
                            {
                                SocketValue val = entry.Value;
                                client.SendValue(entry.Value, message.FromID);
                            }
                        }

                        break;
                    default:
                        break;
                }

                message = null;
            }
        }
Пример #6
0
        void MakeSocketClick(object sender, EventArgs e)
        {
            for (var x=0;x<1000; x++)
            {
                for (var i = 0; i<100; i++)
                {
                    using(var client = new SocketClient("127.0.0.1", 911, Program.ErrorLog, Program.DebugLog))
                    {
                        client.SetValue("sarTesting", AssemblyInfo.Version, true);

                        Thread.Sleep(250);
                    }
                }

                System.GC.Collect();
                Thread.Sleep(1250);
            }
        }