Пример #1
0
 /// <summary>
 /// Input button for sending messages to the server from the network text box
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void InputEnterButton_Click(object sender, EventArgs e)
 {
     // Send the filename to the server that the user requests
     if (networkInputTextbox.Text.Length > 1)
     {
         networkInfoTextBox1.Text = networkInfoTextBox1.Text + "\n" + networkInputTextbox.Text;
         StaticNetworking.Send(spreadsheetState.Socket, networkInputTextbox.Text + "\n");
     }
 }
Пример #2
0
        /// <summary>
        /// Receive the updates to the state from the server and process updates.
        /// </summary>
        /// <param name="state"></param>
        public void ReceiveSpreadsheetUpdates(SocketState state)
        {
            state.callMe = ReceiveSpreadsheetUpdates;
            StaticNetworking.GetData(state);

            // Retrieve string message from state
            //string[] s = state.SB.ToString().Split('\n');
            //Byte[] b = state.MessageBuffer;

            // Lock the spreadsheet while data processes
            // Process data

            // Clear the stringbuilder for the next round of messages from the server
        }
Пример #3
0
        /// <summary>
        /// Receive the startup information from the server and process.
        /// </summary>
        /// <param name="state"></param>
        public void ReceiveStartup(SocketState state)
        {
            state.callMe = ReceiveInitialSpreadsheet;
            StaticNetworking.GetData(state);
            spreadsheetState = state;

            // Retrieve string message from state
            Byte[]   b = state.MessageBuffer;
            string[] s = state.SB.ToString().Split('\t');

            // Lock the spreadsheet while data processes
            lock (spreadsheetState)
            {
                // Process startup data for requesting file from server
                openOrCreateFile(b, s);
            }

            // Clear the stringbuilder for the next round of messages from the server
            state.SB.Clear();
        }
Пример #4
0
 private void DoWork(object sender, DoWorkEventArgs e)
 {
     //Connect to the server
     StaticNetworking.ConnectToServer(FirstContact, IPTextBox.Text);
 }
Пример #5
0
        // SERVER CONNECTION WORK BEGINS HERE

        /// <summary>
        /// Initial handshake with the server
        /// </summary>
        /// <param name="state"></param>
        public void FirstContact(SocketState state)
        {
            state.callMe = ReceiveStartup;
            StaticNetworking.Send(state.Socket, UsernameTextBox.Text + "\n");
        }