Introduction to the Open source. NET Communication Framework NETWORKCOMMS framework three pass list

Source: Internet
Author: User

Original URL: Http://www.cnblogs.com/csdev

Networkcomms is a C # language written by TCP/UDP communication framework The author is the British used to charge the current author has open source address is: Https://github.com/MarcFletcher/NetworkComms.Net

This section tells you how to get list data from the server

Example diagram:

Customer single click Get Data return data from server

Client code:

  Private voidButton4_Click (Objectsender, EventArgs e) {            //Getuserlist is the request message type of the data//Resuserlist is the server-side return message type when the server returns resuserlist data when the client automatically corresponds to getilist<user> Listuser = newtcpconnection.sendreceiveobject<string, Ilist<user>> ("getuserlist","resuserlist", the," -");        Binddata (Listuser); }         Public voidBinddata (ilist<user>theusers)            {listView1.Items.Clear ();            ListView1.Columns.Clear (); Listview1.view= View.Details;//New Detailed waysListview1.allowcolumnreorder =true; Listview1.fullrowselect=true; Listview1.gridlines=true; LISTVIEW1.COLUMNS.ADD ("User ID", -, HorizontalAlignment.Left); LISTVIEW1.COLUMNS.ADD ("User name", -, HorizontalAlignment.Left); foreach(User theuserinchtheusers) {ListViewItem Li=NewListViewItem (); Li. subitems[0]. Text =theUser.UserID.ToString (); Li.                SubItems.Add (Theuser.name);            ListView1.Items.Add (LI); }                }

Server-side code:

  Private voidButton1_Click (Objectsender, EventArgs e) {            //IP address and portIPEndPoint Thepoint =NewIPEndPoint (Ipaddress.parse (Txtip.text),int.            Parse (Txtport.text)); //start listening for this IP and port using the TCP protocolconnection.startlistening (connectiontype.tcp, thepoint); Networkcomms.appendglobalincomingpackethandler<string> ("GetName", Incomingmsghandle); Networkcomms.appendglobalincomingpackethandler<User> ("Userlong", Incoinghandlelogin); Networkcomms.appendglobalincomingpackethandler<string> ("getuserlist", incoinghandlegetuserlist); Button1. Text="already started listening ."; }
  Private voidIncoinghandlegetuserlist (packetheader header, Connection Connection,stringparam) {             //simulate some dataIlist<user> userlist=NewList<user>(); User User1=NewUser (); User1. UserID="10000"; User1. Name="Tianya at this time"; User User2=NewUser (); User2. UserID="20000"; User2. Name="The Moon shines on the sea"; if(param = =" -") {userlist.add (user1);            Userlist.add (User2); }            Else{userlist.add (user1); } connection. SendObject ("resuserlist", userlist); }

SOURCE Download: Http://pan.baidu.com/s/1geXMSef

Introduction to the Open source. NET Communication Framework NETWORKCOMMS framework three pass list

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.