Esempio n. 1
0
		public void Init() {
			bShuttingDown=false;
			iTickShutdown=0;
			iTicksToShutdown=10000;
			packetCorrupt = new Packet();
			packetServerShutdown=new Packet();
			//packetLogin=new Packet();
			packetTemp = new Packet();
			packetCorrupt.iTokenNum = PacketToken.Hidden;
			packetCorrupt.iType = PacketType.ServerMessage;
			packetCorrupt.Set(0,"An packet corruption has been detected by the server.  Try logging in again.");
			packetServerShutdown.iType = PacketType.ServerMessage;
			packetServerShutdown.iTokenNum=PacketToken.Hidden;
			packetServerShutdown.iTickSent = PlatformNow.TickCount;
			packetServerShutdown.Set(0,"Server is Shutting down!");
			packetServerShutdown.sFrom="Server";
			//init other objects now that special Packets are ready to use:
			try {
				packetqIn = new PacketQ();
				accountant = new Accountant();
				packetqarr = new PacketQ[Accountant.MaxUsers];
				coreInServer = new Core();
				
				deltsPacketer = new ThreadStart(Packeting);
		 		tPacketer = new Thread(deltsPacketer); //Thread tPacketer = new Thread(new ThreadStart(Server()));
		  		tPacketer.Start();
				coreInServer.Start();
			}
			catch (Exception exn) {
				RReporting.ShowExn(exn,"Packeter Init","starting Server packeter object");
			}
			RReporting.WriteLine("Server packeter initialized.");
		}
Esempio n. 2
0
        public Gradient()
        {
            PixelYhsa pxUpper = null;
            PixelYhsa pxLower = null;
            bool      bGood   = true;

            try {
                pxUpper = new PixelYhsa(1, 0, 0, 1);
                pxLower = new PixelYhsa(0, 0, 0, 0);
                if (pxUpper == null)
                {
                    bGood = false;
                    RReporting.ShowErr("Couldn't allocate pixel (upper)", "Gradient");                   //TODO: remove this line, for performance
                }
                if (pxLower == null)
                {
                    bGood = false;
                    RReporting.ShowErr("Couldn't allocate pixel (lower)", "Gradient");                   //TODO: remove this line, for performance
                }
                if (bGood)
                {
                    RReporting.Write("Create gradient...");
                    bGood = From(ref pxUpper, ref pxLower);
                    RReporting.WriteLine(bGood?"Success.":"Failed!");
                }
                else
                {
                    RReporting.ShowErr("Create gradient failed!", "Gradient constructor");
                }
            }
            catch (Exception exn) {
                bGood = false;
                RReporting.ShowExn(exn, "Gradient()", "initializing");
            }
        }
Esempio n. 3
0
 public bool UpdateStatus()
 {
     try {
         //sbX.Refresh();
         RReporting.WriteLine(sLast);
     }
     catch (Exception exn) {
         RReporting.IgnoreExn(exn, "MyCallback UpdateStatus(void)");
         return(false);
     }
     return(true);
 }
Esempio n. 4
0
 //private Packet packetMoving;
 /////////// Initialization /////////////
 public Port()           //default constructor called by Server (unless existing manually configured instance is published)
 //packetMoving=new Packet();
 {
     Init();
     try {
         RReporting.WriteLine("Port constructor: defaulting to server mode");
         packeter = new Packeter();                 //server = new Server( );
     }
     catch (Exception exn) {
         RReporting.ShowExn(exn, "Port constructor");
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Use this constructor instead of the default constructor,
        /// otherwise the client will not be able to initialize
        /// </summary>
        Client(string sServerURL1, ref RetroEngine ParentX)
        {
            sFuncNow  = "Client(" + sServerURL1 + ",...)";
            Parent    = ParentX;
            bContinue = true;
            try {
                packetOut = new Packet();
                //Script scriptIni = new Script();//srNow=File.OpenText(sFile);
                //scriptIni.ReadScript("Client.ini");
                //if (!scriptIni.bErr) {

                if (sServerURL1.StartsWith("http://"))                 //debug if non-http
                {
                    sServerURL = sServerURL1;
                }
                else
                {
                    RReporting.Error_WriteLine("-sServerURL defaulted to " + sServerURL);
                }


                //Create and register remoting channel
                HttpChannel chanRetroEngine = new HttpChannel();
                ChannelServices.RegisterChannel(chanRetroEngine);
                bServer = ClientConnectServer();                 //Init the remoting system
                if (!bServer)
                {
                    RReporting.Error_WriteLine("Couldn't connect to server or single-player game. Both require that you check your firewall settings.");
                }

                //string sOS = Environment.OSVersion.ToString;
                //System.PlatformID platformidOS = Environment.OSVersion.Platform;
                //System.Version versionOS = Environment.OSVersion.Version;
                //System.Type typeOS = Environment.OSVersion.GetType;
                portServer       = new Port();           //new Port("client");
                tsClientPacketer = new ThreadStart(ClientPacketer);
                tClientPacketer  = new Thread(tsClientPacketer);
                tClientPacketer.Start();
                coreInClient = new Core();                 //this is just the mapper not the server
                coreInClient.Start();
            }
            catch (Exception exn) {
                if (bServer)
                {
                    RReporting.WriteLine("Couldn't initialize client");
                    RReporting.ShowExn(exn, "Client constructor", "initializing client");
                }
                //bContinue==false;
            }
            //ProgramMain();
        }
Esempio n. 6
0
 private void Scenarior()
 {
     //runs as a Thread to put core.scenario into motion.
     //thread should be used by server AND client (but does client use server???) (?)
     RReporting.WriteLine("Scenario manager started");
     while (bContinue)
     {
         //if (bShuttingDown) {
         //if (iPacketsSending==0) bContinue=false; //debug this statement should be fixed and used
         //	if (RetroEngine.TickCount-iTickShutdown>iTicksToShutdown) bContinue=false;
         //}
     }
     RReporting.WriteLine("Scenario manager stopped");
 }
Esempio n. 7
0
  		private void Packeting() {
			int iPort = 61100; //read from ini later
			string sName = "RetroEngineServer"; //read from ini later
			bool bGood=false;
			//Script scriptIni;
			HttpChannel chanRetroEngine=null;
			//sIni="Server.ini";
			bGood=true;
			if (iPort<1024) {
				iPort=61100;
				RReporting.Error_WriteLine("  -Port was reset to "+iPort.ToString()+" because the config file was bad");
			}
			RReporting.Error_WriteLine("  -Port = "+iPort.ToString());
			RReporting.Error_WriteLine("  -Server name = "+sName);
			if (iPort<1024) bGood=false; //debug NYI if not in standard set of allowed (high-number) ports
			if (bGood) {
				//Create&register channel
				chanRetroEngine = new HttpChannel(iPort);
				ChannelServices.RegisterChannel(chanRetroEngine);
				//Register and count server for remoting
				RemotingConfiguration.RegisterWellKnownServiceType(
					typeof(Port), sName,
					WellKnownObjectMode.Singleton);
			}
			else {
				//scriptIni.Dump();
				RReporting.Error_WriteLine("The server was not initialized because the port number either set or loaded improperly in initialization file!");
			}
			
			
			//if () bContinue=true;
			Packet packetNow;
			bool bEmpty=true;
			while (bContinue) {
				if (bShuttingDown) {
					//if (iPacketsSending==0) bContinue=false; //debug this statement should be fixed and used
					if (PlatformNow.TickCount-iTickShutdown>iTicksToShutdown) bContinue=false;
				}
				if (packetqIn!=null) {
					try {
						try {
							bEmpty=packetqIn.IsEmpty;
						}
						catch (Exception exn) {
							RReporting.ShowExn(exn,"Packeting","checking whether packetqIn IsEmpty");
							bEmpty=true;
						}
						if (!bEmpty) {
							//Now Run the next Packet
							packetNow = packetqIn.Deq();
							if (packetNow==null) RReporting.ShowErr(" (packetq) packet in non-empty queue was null","Packeting");
							else RunPacket(ref packetNow);
						}//end if not empty
					}
					catch (Exception exn) {
						RReporting.ShowExn(exn,"Packeting","trying to process next incoming packet");
					}
				}
				else RReporting.ShowErr("packetqIn is not initialized correctly.","Packeting"); 
			}
			RReporting.WriteLine("Packeting stopped.");
				//if (tPacketer!=null && tPacketer.IsRunning) tPacketer.Abort(); //is this possible (To exit self)?? //debug
		}//end Packeting