Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS590VC – Tutorial 6 Client-side connection through external application.

Similar presentations


Presentation on theme: "CS590VC – Tutorial 6 Client-side connection through external application."— Presentation transcript:

1 CS590VC – Tutorial 6 Client-side connection through external application

2 LibSecondLife Project An effort directed at understanding how Second Life works from a technical perspective. Extending and integrating with the rest of the web. Understanding how the official Second Life client operates Understanding how it communicates with the Second Life simulator servers Development of independent third party clients and tools

3 Brief Technicalities libsecondlife runs in a.Net virtual machine. libsecondlife is written in C# using Microsoft.NET. We will be using Windows platform.

4 How to use libsecondlife in Visual Studio

5 Step 1: Create new project

6 Step 2: Select “Console Application” under Visual C# -> Windows

7 You write the code now

8 Step 3: Copy the given code in the editor using System; using System.Collections.Generic; using System.Linq; using System.Text; using OpenMetaverse; namespace ConsoleApplication3 { class Program { public static GridClient Client = new GridClient(); private static string first_name = "First"; private static string last_name = "Last"; private static string password = "password";

9 Code contd.. static void Main(string[] args) { Client.Network.LoginProgress += new EventHandler (Network_LoginProgress); if (Client.Network.Login(first_name, last_name, password, "My First Bot", "Your name")) { Console.WriteLine("I logged into Second Life!"); } else { Console.WriteLine("I couldn't log in, here is why: " + Client.Network.LoginMessage); Console.WriteLine("press enter to close..."); Console.ReadLine(); }

10 Code contd.. static void Network_LoginProgress(object sender, LoginProgressEventArgs e) { if (e.Status == LoginStatus.Success) { Console.WriteLine("I'm connected to the simulator, going to greet everyone around me"); Client.Self.Chat("Hello World!", 0, ChatType.Normal); Console.WriteLine("Now I am going to logout of SL.. Goodbye!"); Client.Network.Logout(); Console.WriteLine("I am Loged out please press enter to close..."); Console.ReadLine(); }

11 Step 4: Click “Solution Explorer” Solution explorer Right click on “References” -> Add References

12 Step 5: Select “Browse” -> select “bin” of the “libsecondlife-0_4_1_1-binary” folder Select “OpenMetaverse.dll.dll”

13 Select “Browse” -> select “bin” of the “libsecondlife-0_4_1_1-binary” folder Select “OpenMetaverseTypes.dll”

14 Select “Browse” -> select “bin” of the “libsecondlife-0_4_1_1-binary” folder Select “OpenMetaverse.StructuredData.dll

15 Step 6: Compilation “OpenMetaverseTypes.dll” OpenMetaverseTypes.dll OpenMetaverse.StructuredData.dll added Build successful

16 Code Explanation 1: using OpenMetaverse; This tells the compiler to include the contents of the OpenMetaverse library when compiling this file, put this at the top of all files using any of the libsecondlife classes. public static GridClient Client = new GridClient(); This line is probably the most important line in any libsecondlife application. It contains all of the functions that are required for your bot to communicate with the Second Life grid. [Usually this variable is named "client," but you can call it whatever you want.]

17 Code Explanation 2: Client.Network.LoginProgress += new EventHandler (Network_LoginProgress); The LoginProgressis an Event (found under the Network class in your SecondLife variable). Basically, whenever your bot connects to a simulator (server side) and marks its presence there, it will fire the Network_LoginProgress method (Event Handler). [This event handler has to be coded according to your application. Defines what the bot should do when it logs in] if (client.Network.Login(first_name, last_name, password, "My First Bot", "Your name")) The bot logs in with the login information.

18 How to run the bot Go to the Debug menu at the top of Visual Studio and click "Start Debugging" If everything went according to plan, you should see a windows console pop up

19 References http://www.libsecondlife.org/wiki/ http://www.libsecondlife.org/builds/ - for installation http://www.libsecondlife.org/builds/ [build ver.: libsecondlife-0_4_1_1-binary.zip]libsecondlife-0_4_1_1-binary.zip


Download ppt "CS590VC – Tutorial 6 Client-side connection through external application."

Similar presentations


Ads by Google