상속: System.EventArgs
예제 #1
0
        private void ReadCallback(IAsyncResult ar)
        {
            recieveDone.Set();

            String content = String.Empty;

            StateObject state = (StateObject)ar.AsyncState;
            Socket handler = state.workSocket;

            int bytesRead = handler.EndReceive(ar);

            if (bytesRead > 0)
            {
                state.sb.Append(Encoding.ASCII.GetString(state.buffer,
                                0, bytesRead));
                content = state.sb.ToString();

                String[] data = content.Split(';');

                if(data[0].Equals("reply"))
                {
                    ConnectionAcceptEventArgs e = new ConnectionAcceptEventArgs(data[1]);
                    OnConnectionAccept(e);
                }
                else if(data[0].Equals("startgame"))
                {
                    ConnectionRequestEventArgs e = new ConnectionRequestEventArgs(data[1]);
                    OnConnectionRequest(e);
                }
                else if(data[0].Equals("step"))
                {
                    StepEventArgs e = new StepEventArgs(deserializeToObject(state.buffer,5));
                    OnStep(e);
                }

            }
        }
예제 #2
0
 protected virtual void OnStep(StepEventArgs e)
 {
     StepEventHandler handler = stepEventHandler;
     if (handler != null)
     {
         handler(this, e);
     }
 }