Exemplo n.º 1
0
 void manager_get_message(TCPEventArgs args)
 {
     RunOnUiThread(() =>
     {
         lst_info.Text = lst_info.Text + "GET : " + args.message + "\n";
     });
 }
Exemplo n.º 2
0
 void myclient_get_message(TCPEventArgs args)
 {
     if (statues_update != null)
     {
         ManagerEventArgs mes = new ManagerEventArgs();
         mes.message = args.message;
         statues_update(mes);
     }
 }
Exemplo n.º 3
0
        void read_recive(string msg)
        {
            //MSG IS MESSAGE FROM THAT CLIENT - PROTOCOL ANALYSIS HERE :
            //SHOW CLIENT MESSAGE IN INFO LISTVIEW
            TCPEventArgs mes = new TCPEventArgs();

            mes.message = msg;
            mes.from    = this;
            if (get_message != null)
            {
                get_message(mes);
            }
        }
Exemplo n.º 4
0
        private void HandleClientComm()
        {
            //GET NETWORK STREAM
            NetworkStream clientStream = client.GetStream();

            byte[] message = new byte[4096];
            int    bytesRead;

            while (server_manager.active)
            {
                bytesRead = 0;

                try
                {
                    //BLOCKED FOR NEW MESSAGE
                    bytesRead = clientStream.Read(message, 0, 4096);
                }
                catch
                {
                    //ERROR OR DISCONNECT
                    break;
                }

                if (bytesRead == 0)
                {
                    //ERROR OR DISCONNECT
                    break;
                }

                //READ DONE - CONVERT TO UTF8 STRING
                string read_str = Encoding.UTF8.GetString(message, 0, bytesRead);
                read_recive(read_str);
            }

            TCPEventArgs mes = new TCPEventArgs();

            mes.from    = this;
            mes.message = "Disconned";
            if (get_message != null)
            {
                get_message(mes);
            }

            server_manager.client_list.Remove(this);


            client.Close();
            client = null;
        }