public void Go() { network = new NetworkLevel2Controller(); network.ConnectAsClient(serveraddress, serverport); network.NewConnection += new Level2NewConnectionHandler(network_NewConnection); while (true) { network.Tick(); Thread.Sleep(50); } }
public void Go() { net = new NetworkLevel2Controller(); net.ConnectAsClient("127.0.0.1", 3456); net.NewConnection += new Level2NewConnectionHandler(net_NewConnection); net.Disconnection += new Level2DisconnectionHandler(net_Disconnection); net.RegisterPacketConsumer('Z', new Level2ReceivedPacketHandler(net_ReceivedPacket)); //net.ReceivedPacket += new Level2ReceivedPacketHandler(net_ReceivedPacket); while (true) { net.Tick(); //net.ConnectionToServer.Send( 'P', Encoding.ASCII.GetBytes( "sample data " + i.ToString() ) ); Thread.Sleep(50); // i++; } }
public void ConnectToServer(string ipaddressstring, int port) { IPAddress[] addresses = System.Net.Dns.GetHostAddresses(ipaddressstring); if (addresses.GetLength(0) == 0) { return; } IPAddress ipaddress = addresses[0]; LogFile.WriteLine("Resolved server address to : " + ipaddressstring); try { network.ConnectAsClient(ipaddress.ToString(), port); } catch (Exception e) { DialogHelpers.ShowErrorMessageModal(null, "Failed to connect to server"); LogFile.WriteLine(e.ToString()); } SelectionModel.GetInstance().Clear(); worldstorage.Clear(); }
public int Init( IConfigSource commandlineConfig, IClientControllers controllers ) { Type type = Type.GetType( "OSMP.ObjectReplicationClientToServer" ); LogFile.WriteLine( "type: [" + type + "] " + type.AssemblyQualifiedName ); //System.Environment.Exit( 0 ); Tao.DevIl.Il.ilInit(); Tao.DevIl.Ilu.iluInit(); config = Config.GetInstance(); string serverip = commandlineConfig.Configs["CommandLineArgs"].GetString( "serverip", config.ServerIPAddress ); int port = commandlineConfig.Configs["CommandLineArgs"].GetInt( "serverport", config.ServerPort ); network = new NetworkLevel2Controller(); network.NewConnection += new Level2NewConnectionHandler(network_NewConnection); network.ConnectAsClient(serverip, port); rpc = new RpcController(network); netreplicationcontroller = new NetReplicationController(rpc); renderer = RendererFactory.GetInstance(); renderer.Tick += new OSMP.TickHandler( MainLoop ); renderer.Init(); worldstorage = new WorldModel(netreplicationcontroller); worldview = new WorldView( worldstorage ); playermovement = PlayerMovement.GetInstance(); InitializePlayermovement(); myavatar = new Avatar(); worldstorage.AddEntity(myavatar); controllers.Plugin.LoadClientPlugins(); if (!commandlineConfig.Configs["CommandLineArgs"].Contains("nochat" )) { LoadChat(); } if( commandlineConfig.Configs["CommandLineArgs"].Contains("url" ) ) { string url = commandlineConfig.Configs["CommandLineArgs"].GetString("url" ); LogFile.WriteLine( "url: " + url); if (url.StartsWith( "osmp://" )) { targettoload = "http://" + url.Substring( "osmp://".Length ); LogFile.WriteLine( "target: " + targettoload ); } else { targettoload = url; } } renderer.StartMainLoop(); return 0; }
public int Init(IConfigSource commandlineConfig, IClientControllers controllers) { Type type = Type.GetType("OSMP.ObjectReplicationClientToServer"); LogFile.WriteLine("type: [" + type + "] " + type.AssemblyQualifiedName); //System.Environment.Exit( 0 ); Tao.DevIl.Il.ilInit(); Tao.DevIl.Ilu.iluInit(); config = Config.GetInstance(); string serverip = commandlineConfig.Configs["CommandLineArgs"].GetString("serverip", config.ServerIPAddress); int port = commandlineConfig.Configs["CommandLineArgs"].GetInt("serverport", config.ServerPort); network = new NetworkLevel2Controller(); network.NewConnection += new Level2NewConnectionHandler(network_NewConnection); network.ConnectAsClient(serverip, port); rpc = new RpcController(network); netreplicationcontroller = new NetReplicationController(rpc); renderer = RendererFactory.GetInstance(); renderer.Tick += new OSMP.TickHandler(MainLoop); renderer.Init(); worldstorage = new WorldModel(netreplicationcontroller); worldview = new WorldView(worldstorage); playermovement = PlayerMovement.GetInstance(); InitializePlayermovement(); myavatar = new Avatar(); worldstorage.AddEntity(myavatar); controllers.Plugin.LoadClientPlugins(); if (!commandlineConfig.Configs["CommandLineArgs"].Contains("nochat")) { LoadChat(); } if (commandlineConfig.Configs["CommandLineArgs"].Contains("url")) { string url = commandlineConfig.Configs["CommandLineArgs"].GetString("url"); LogFile.WriteLine("url: " + url); if (url.StartsWith("osmp://")) { targettoload = "http://" + url.Substring("osmp://".Length); LogFile.WriteLine("target: " + targettoload); } else { targettoload = url; } } renderer.StartMainLoop(); return(0); }