void manager_get_message(TCPEventArgs args) { RunOnUiThread(() => { lst_info.Text = lst_info.Text + "GET : " + args.message + "\n"; }); }
void myclient_get_message(TCPEventArgs args) { if (statues_update != null) { ManagerEventArgs mes = new ManagerEventArgs(); mes.message = args.message; statues_update(mes); } }
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); } }
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; }