Beispiel #1
0
 void mcClient_RaiseMsgRcvEvent(object sender, MessageReceivedArgs msgRcvArgs)
 {
     string dataRcv = msgRcvArgs.Message;
     string[] dataArray = dataRcv.Split(new char[] { ' ' });
     if (dataArray.Length > 0)
     {
         switch (dataArray[0])
         {
             case "n":
                string nextWord = dis.NextWord();
                 _distractor.Text = nextWord;
             default:
                 break;
         }
     }
 }
Beispiel #2
0
 void mcServer_RaiseMsgRcvEvent(object sender, MessageReceivedArgs msgRcvArgs)
 {
     string dataRcv = msgRcvArgs.Message;
     string[] dataArray = dataRcv.Split(new char[] { ' ' });
     if (dataArray.Length > 0)
     {
         switch (dataArray[0])
         {
             case "pt":
                 FetchSchedule();
                 break;
             default:
                 break;
         }
     }
 }
        private void ReadCallback(IAsyncResult ar)
        {
            String content = String.Empty;

            // Retrieve the state object and the handler socket
            // from the asynchronous state object.
            StateObject state = (StateObject)ar.AsyncState;
            Socket handler = state.workSocket;

            // Read data from the client socket.
            int bytesRead = handler.EndReceive(ar);

            if (bytesRead > 0)
            {
                // There  might be more data, so store the data received so far.
                string dataStr = Encoding.ASCII.GetString(
                    state.buffer, 0, bytesRead);
                MessageReceivedArgs args = new MessageReceivedArgs(dataStr);
                MessageReceivedEventHandler raiseEvent = RaiseMsgRcvEvent;
                if (raiseEvent != null) raiseEvent(this, args);

                // Not all data received. Get more.
                handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0,
                new AsyncCallback(ReadCallback), state);
            }
        }