Exemplo n.º 1
0
        static void Main(string[] args)
        {
            LogOut.Action += LogOut_Action;
            ZYNetClient client = new ZYNetClient();

            client.Connect(RConfig.ReadString("Host"), RConfig.ReadInt("ServicePort"));
            client.DataInput         += Client_ClientDataIn;
            client.ConnectToMe       += Client_ClientConnToMe;
            client.SessionDisconnect += Client_ClientDiscon;
            client.ServerDisconnect  += Client_ServerDisconnect;



            while (true)
            {
                byte[] data = Encoding.Default.GetBytes(Console.ReadLine());

                client.SendDataToALLClient(data);
            }
        }
Exemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            map = new Bitmap(this.panel1.Width, this.panel1.Height);

            gs  = Graphics.FromImage(map);
            gs2 = this.panel1.CreateGraphics();

            Br = new SolidBrush(Color.FromArgb(new Random().Next()));

            Client = new ZYNetClient();
            if (Client.Connect(ZYSocket.share.RConfig.ReadString("host"), ZYSocket.share.RConfig.ReadInt("ServicePort")))
            {
                LogOn tmp = new LogOn(Client);
                tmp.ShowDialog();

                if (tmp.IsLogOn)
                {
                    Client.ServerDisconnect += Client_ServerDisconnect;
                    Client.DataInput        += Client_DataInput;

                    UserCount count = new UserCount();
                    Client.SendDataToServer(BufferFormat.FormatFCA(count));

                    this.Text = tmp.Names;
                }
                else
                {
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("无法连接服务器");
                this.Close();
            }
        }