示例#1
0
        public bool Connect(string ipAddress, int port)
        {
            try
            {
                IPAddress ip = IPAddress.Parse(ipAddress);
                tcpClient.Connect(ipAddress, port);

                networkStream = tcpClient.GetStream();

                reader    = new BinaryReader(networkStream, Encoding.UTF8);
                writer    = new BinaryWriter(networkStream, Encoding.UTF8);
                formatter = new BinaryFormatter();

                updateChatWindowDelegate = new UpdateChatWindowDelegate(UpdateChatWindow);

                gameUpdateDelegate = new GameUpdateDelegate(XO_GameUpdate);

                tcpThread = new Thread(new ThreadStart(ProcessServerResponse));
                tcpThread.Start();

                UdpThread = new Thread(new ThreadStart(UdpProcessServerResponse));
                UdpThread.Start();

                udpEndPoint = new IPEndPoint(ip, port);
                udpSocket.Connect(udpEndPoint);
            }
            catch (Exception e)
            {
                chatWindow.Text += "{0} Exception Caught: " + e + "\n";
                return(false);
            }
            connected = true;
            return(true);
        }
示例#2
0
        public ClientForm(SimpleClient client)
        {
            _client = client;
            InitializeComponent();
            _updateChatWindowDelgate = new UpdateChatWindowDelegate(UpdateChatWindow);

            ControlSelect(SubmitText);
        }
示例#3
0
        public ClientForm(object _client)
        {
            InitializeComponent();
            _updateChatWindowDelegate       = new UpdateChatWindowDelegate(UpdateChatWindow);
            _updateConnectedClientsDelegate = new UpdateConnectedClientsDelegate(UpdateClientListBox);
            Client = (SimpleClient)_client;

            inputChat.Select();
        }
 public Form1()
 {
     udpSocket  = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
     IPEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 4444);
     udpSocket.Connect(IPEndPoint);
     formatter = new BinaryFormatter();
     tcpClient = new TcpClient();
     updateChatWindowDelegate = new UpdateChatWindowDelegate(UpdateChatWindow);
     InitializeComponent();
 }
示例#5
0
        public ChatWindow(SimpleClient client)
        {
            InitializeComponent();

            _updateChatWindowDelegate = new UpdateChatWindowDelegate(UpdateChatWindow);
            _clearChatWindowDelegate  = new ClearChatWindowDelegate(ClearChatWindow);

            _client = client;
            if (messageBox.CanSelect)
            {
                messageBox.Select();
            }
        }
示例#6
0
        public ClientForm(SimpleClient.SimpleClient client)
        {
            InitializeComponent();
            updateChatWindowDelegate    = new UpdateChatWindowDelegate(UpdateChatWindow);
            updateClientListBoxDeletage = new UpdateClientListBoxDelegate(UpdateClientListBox);
            Client = client;

            InputMessage.Select();

            button2.Enabled   = false;
            comboBox1.Enabled = false;
            button3.Enabled   = false;
            isConnected       = false;
        }
示例#7
0
 public ChatClient()
 {
     tcpClient = new TcpClient();
     _updateChatWindowDelegate = new UpdateChatWindowDelegate(UpdateChatWindow);
     InitializeComponent();
 }
示例#8
0
 public Form1(Manager manager)
 {
     Manager = manager;
     InitializeComponent();
     updateChatWindowDelegate += new UpdateChatWindowDelegate(UpdateChatWindow);
 }