Пример #1
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