This project is read-only.

Can't create Distributed Object Tank sample

Mar 30, 2012 at 8:46 PM

Hi I hope this project isn't dead?

Client side doesn't seem to work:

Client connected. Creating tank Key: 1585399963 False

from below no matter how I use CreateObject or DistributeObject

else if (DistributionSession.Client.Status == NetConnectionStatus.Connected)
	  Debug.Log("Client is connected.");
           if (tank == null)
		tank = new Tank();
                // tank = new Chatter();
		//tank = DistributionSession.CreateObject<KaletaTest>();
		tank.X += 10; // note I've moved this up and down
		//tank.Creator = new DistributableString("Guest["+tank.Key.ToString()+"]");			
                //Debug.Log("Client connected. Creating chatter. Creator=Guest["+ tank.Key.ToString()+"]");
                Debug.Log("Client connected. Creating tank Key: "+tank.Key.ToString()+" "+tank.IsDistributed);//Creator=Guest["+ localChatter.Key.ToString()+"]");
               } // else tank.X += 5; 

If I try to create the object on the server side I get an exception no matter how I create the object:

starting server
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object  at Kaleta.Network.DistributionSession.CreateObject[Tank] () [0x00000] in <filename unknown>:0   at KaletaServerConsole.KaletaServer.Main (System.String[] args) [0x0002c] in /Users/Tomo/KaletaExample/KaletaServerConsole/KaletaServerConsole/KaletaServer.cs:30 The application was terminated by a signal: SIGHUP

using System;
using Kaleta.Network;
using Lidgren.Network;

namespace KaletaServerConsole
public class KaletaServer {
	NetConfiguration serverConfig = new NetConfiguration("foobar");

	public KaletaServer ()
	serverConfig.Port = 6000;
        serverConfig.MaxConnections = 10;
        NetServer server = new NetServer(serverConfig);

        DistributionSession.Initialize(server, new Type[] { typeof(Tank) });		
	public static void Main(string[] args)
		Console.WriteLine("starting server");
		new KaletaServer();
		Tank tank = null;
		while (!Console.KeyAvailable) 
			if (DistributionSession.Server != null) {
			   if (tank == null) {
				tank = //new Tank();
				foreach (DistributableObject obj in DistributionSession.DistributableObjects.Values)
                		if (obj is Tank)
					Console.WriteLine("ServerUpdate... "+((Tank) obj).X);	
					//draw the tank...
		Console.WriteLine("stopping server");

I'm using MonoDevelop btw.