Provides a stream that implements the AuxSvc protocol.
示例#1
0
 private void testAuxButton_Click(object sender, EventArgs e)
 {
     // Create the AuxSvc Object for your program. This will automatically
     // try to connect to your host/port and prepare you to be able to 
     // send your information to POL.
     AuxSvcConnection TestAuxSvc = new AuxSvcConnection(serverHost.Text.ToString(), Convert.ToInt32(serverPort.Text));
     if (!TestAuxSvc.Active)
     {
         MessageBox.Show("Server appears to be offline. Make sure host and port are correct.");
         return;
     }
     TestAuxSvc.Write(PackUnpack.Pack(auxSendText.Text.ToString()));
     string ReadString = TestAuxSvc.Read();
     object ReadObject = PackUnpack.Unpack(ReadString.ToString());
     ArrayList ReadArray = (ArrayList)ReadObject;
     auxRecvText.Text = ReadArray[0] + " " + ReadArray[1] + " " + ReadArray[2];
     TestAuxSvc.Close();
 }
示例#2
0
        private void BTN_CreateAccount_Click(object sender, EventArgs e)
        {
            if (POLConsole == null)
            {
                MessageBox.Show("POL does not appear to be running via POL Launch.");
                return;
            }

            // Checks to make sure everything was filled out, or if can use defaults.
            if (TB_CreateUsername.Text.Length < 3)
            {
                MessageBox.Show("Usernames must be at least 3 characters long.");
                return;
            }
            if (TB_CreatePassword.Text.Length < 3)
            {
                MessageBox.Show("Passwords must be at least 3 characters long.");
                return;
            }
            if (TB_CreateEmail.Text.IndexOf("@") == -1)
                TB_CreateEmail.Text = "*****@*****.**";
            
            ArrayList NewAccountInfo = new ArrayList {
                                      TB_CreateUsername.Text,
                                      TB_CreatePassword.Text,
                                      LBX_CreateCmdlevel.SelectedIndex,
                                      LBX_CreateExpansion.SelectedIndex,
                                      TB_CreateEmail.Text,
                                      };
            if (TB_CreateAuxPassword.Text.Length > 0)
                NewAccountInfo.Add(TB_CreateAuxPassword.Text);
            AuxSvcConnection CreateAuxSvc = new AuxSvcConnection("localhost", Convert.ToInt32(TB_CreateAccountPort.Text));
            if (!CreateAuxSvc.Active)
            {
                MessageBox.Show("Server appears to be offline. Make sure Port is correct.");
                return;
            }
            CreateAuxSvc.Write(PackUnpack.Pack(NewAccountInfo));
            string RcvString = CreateAuxSvc.Read();
            object ResultObject = PackUnpack.Unpack(RcvString);
            
            // This is where we convert the Object back to what it needs to be.
            // Arrays are converted to ArrayList for storage of both Int and String
            // In the Account Creation only Arrays are being returned. The first
            // Element says "Error" or "Success", and the second is the string reason.
            string ResultMsg = "";
            string CaptionMsg = "";
            if (ResultObject.GetType() == typeof(ArrayList))
            {
                Convert.ChangeType(ResultObject, typeof(ArrayList));
                foreach (object Elem in (ArrayList)ResultObject)
                {
                    string NewElem = Convert.ToString(Elem);
                    if (NewElem.IndexOf("Error") != -1 || NewElem.IndexOf("Success") != -1)
                    {
                        CaptionMsg = Convert.ToString(Elem);
                    }
                    else
                        ResultMsg += NewElem;
                }
            }

            MessageBox.Show(ResultMsg, CaptionMsg);
        }