Began to create grid server framework

ogs-cs
gareth 2007-03-08 00:50:57 +00:00
parent e96573b535
commit 646f8bf186
7 changed files with 222 additions and 58 deletions

View File

@ -50,6 +50,11 @@ namespace ServerConsole
}
}
public abstract class conscmd_callback {
public abstract void RunCmd(string cmd, string[] cmdparams);
public abstract void Show(string ShowWhat);
}
public abstract class ConsoleBase
{

View File

@ -1,6 +1,5 @@
<?xml version="1.0"?>
<project name="OpenSim" default="build" basedir=".">
<description>nant buildfile for OpenSim</description>
<project name="ServerConsole" default="build" basedir=".">
<property name="debug" value="true" overwrite="false" />
<target name="clean" description="remove all generated files">
<delete file="../common/bin/ServerConsole.dll" failonerror="false" />

View File

@ -31,11 +31,9 @@ using System.Collections.Generic;
using System.Threading;
using System.IO;
using System.Net;
using libsecondlife;
using libsecondlife.Packets;
using ServerConsole;
namespace OpenSim
namespace OpenGridServices
{
/// <summary>
/// Description of ServerConsole.
@ -45,32 +43,34 @@ namespace OpenSim
private ConsoleType ConsType;
StreamWriter Log;
public conscmd_callback cmdparser;
public string componentname;
// STUPID HACK ALERT!!!! STUPID HACK ALERT!!!!!
// constype - the type of console to use (see enum ConsoleType)
// sparam - depending on the console type:
// TCP - the IP to bind to (127.0.0.1 if blank)
// Local - param ignored
// SimChat - the AgentID of this sim's admin
// and for the iparam:
// TCP - the port to bind to
// Local - param ignored
// SimChat - the chat channel to accept commands from
public MServerConsole(ConsoleType constype, string sparam, int iparam) {
// LogFile - duh
// componentname - which component of the OGS system? (user, asset etc)
public MServerConsole(ConsoleType constype, string sparam, int iparam, string LogFile, string componentname) {
ConsType = constype;
this.componentname = componentname;
switch(constype) {
case ConsoleType.Local:
Console.WriteLine("ServerConsole.cs - creating new local console");
Console.WriteLine("Logs will be saved to current directory in opensim-console.log");
Log=File.AppendText("opensim-console.log");
Console.WriteLine("Logs will be saved to current directory in " + LogFile);
Log=File.AppendText(LogFile);
Log.WriteLine("========================================================================");
//Log.WriteLine("OpenSim " + VersionInfo.Version + " Started at " + DateTime.Now.ToString());
Log.WriteLine(componentname + VersionInfo.Version + " Started at " + DateTime.Now.ToString());
break;
case ConsoleType.TCP:
break;
case ConsoleType.SimChat:
break;
default:
Console.WriteLine("ServerConsole.cs - what are you smoking? that isn't a valid console type!");
@ -79,7 +79,7 @@ namespace OpenSim
}
public override void Close() {
Log.WriteLine("OpenSim shutdown at " + DateTime.Now.ToString());
Log.WriteLine("Shutdown at " + DateTime.Now.ToString());
Log.Close();
}
@ -141,54 +141,25 @@ namespace OpenSim
// Runs a command with a number of parameters
public override Object RunCmd(string Cmd, string[] cmdparams) {
switch(Cmd) {
case "help":
this.WriteLine("show users - show info about connected users");
this.WriteLine("shutdown - disconnect all clients and shutdown");
break;
case "show":
ShowCommands(cmdparams[0]);
break;
case "shutdown":
OpenSim_Main.Shutdown();
break;
}
cmdparser.RunCmd(Cmd, cmdparams);
return null;
}
// Shows data about something
public override void ShowCommands(string ShowWhat) {
switch(ShowWhat) {
case "uptime":
this.WriteLine("OpenSim has been running since " + OpenSim_Main.sim.startuptime.ToString());
this.WriteLine("That is " + (DateTime.Now-OpenSim_Main.sim.startuptime).ToString());
break;
case "users":
OpenSim.world.Avatar TempAv;
this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}","Firstname", "Lastname","Agent ID", "Session ID", "Circuit", "IP"));
foreach (libsecondlife.LLUUID UUID in OpenSim_Main.local_world.Entities.Keys) {
TempAv=(OpenSim.world.Avatar)OpenSim_Main.local_world.Entities[UUID];
this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}",TempAv.firstname, TempAv.lastname,UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString()));
}
break;
}
}
// Displays a prompt to the user and then runs the command they entered
public override void MainConsolePrompt() {
string[] tempstrarray;
string tempstr = this.CmdPrompt("OpenSim-" + OpenSim_Main.cfg.RegionHandle.ToString() + " # ");
tempstrarray = tempstr.Split(' ');
string cmd=tempstrarray[0];
Array.Reverse(tempstrarray);
Array.Resize<string>(ref tempstrarray,tempstrarray.Length-1);
Array.Reverse(tempstrarray);
string[] cmdparams=(string[])tempstrarray;
RunCmd(cmd,cmdparams);
cmdparser.Show(ShowWhat);
}
public override void MainConsolePrompt() {
string[] tempstrarray;
string tempstr = this.CmdPrompt(this.componentname + "# ");
tempstrarray = tempstr.Split(' ');
string cmd=tempstrarray[0];
Array.Reverse(tempstrarray);
Array.Resize<string>(ref tempstrarray,tempstrarray.Length-1);
Array.Reverse(tempstrarray);
string[] cmdparams=(string[])tempstrarray;
RunCmd(cmd,cmdparams);
}
}
}

View File

@ -0,0 +1,37 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
namespace OpenGridServices
{
/// <summary>
/// </summary>
public class VersionInfo
{
public static string Version = "@@VERSION";
}
}

51
gridserver/default.build Normal file
View File

@ -0,0 +1,51 @@
<?xml version="1.0"?>
<project name="GridServer" default="build" basedir=".">
<property name="debug" value="true" overwrite="false" />
<target name="clean" description="remove all generated files">
<delete file="bin/GridServer.exe" failonerror="false" />
<delete file="bin/GridServer.exe.mdb" failonerror="false" />
</target>
<target name="svnupdate" description="updates to latest SVN">
<exec program="svn">
<arg value="update" />
</exec>
</target>
<target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build">
</target>
<target name="build" description="compiles the source code">
<loadfile file="../VERSION" property="svnver"/>
<asminfo output="AssemblyInfo.cs" language="CSharp">
<imports>
<import namespace="System" />
<import namespace="System.Reflection" />
<import namespace="System.Runtime.InteropServices" />
</imports>
<attributes>
<attribute type="ComVisibleAttribute" value="false" />
<attribute type="CLSCompliantAttribute" value="false" />
<attribute type="AssemblyVersionAttribute" value="${svnver}" />
<attribute type="AssemblyTitleAttribute" value="ogs-GridServer" />
<attribute type="AssemblyDescriptionAttribute" value="The core OGS Grid Server" />
<attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/>
</attributes>
</asminfo>
<csc target="exe" output="bin/GridServer.exe" debug="${debug}" verbose="true" warninglevel="4">
<references failonempty="true">
<include name="System" />
<include name="System.Xml" />
<include name="../common/bin/ServerConsole.dll" />
</references>
<sources>
<include name="../common/src/VersionInfo.cs" />
<include name="../common/src/OGS-Console.cs" />
<include name="src/Main.cs" />
</sources>
</csc>
</target>
</project>

63
gridserver/src/Main.cs Normal file
View File

@ -0,0 +1,63 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Text;
using ServerConsole;
namespace OpenGridServices
{
/// <summary>
/// </summary>
public class OpenGrid_Main
{
public static OpenGrid_Main thegrid;
[STAThread]
public static void Main( string[] args )
{
Console.WriteLine("OpenGrid " + VersionInfo.Version + "\n");
Console.WriteLine("Starting...\n");
ServerConsole.MainConsole.Instance = new MServerConsole(ServerConsole.ConsoleBase.ConsoleType.Local, "", 0, "opengrid-console.log", "OpenGrid");
thegrid = new OpenGrid_Main();
thegrid.Startup();
while(true) {
ServerConsole.MainConsole.Instance.MainConsolePrompt();
}
}
public void Startup() {
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Looking for configuration");
}
}
}

38
ogs.build Normal file
View File

@ -0,0 +1,38 @@
<?xml version="1.0"?>
<project name="OGS" default="build" basedir=".">
<description>nant buildfile for OpenSim</description>
<property name="debug" value="true" overwrite="false" />
<target name="clean" description="remove all generated files">
<nant target="clean">
<buildfiles>
<include name="ServerConsole/default.build" />
<include name="gridserver/default.build" />
</buildfiles>
</nant>
</target>
<target name="svnupdate" description="updates to latest SVN">
<exec program="svn">
<arg value="update" />
</exec>
</target>
<target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build">
</target>
<target name="build" description="compiles the source code">
<exec program="genvers.sh" />
<loadfile file="VERSION" property="svnver"/>
<nant>
<buildfiles>
<include name="ServerConsole/default.build" />
<include name="gridserver/default.build" />
</buildfiles>
</nant>
</target>
</project>