7. Missing link
Server/Client developer
Server (core services/scene code/OMV protocol…)
Client
Server extensions developer
Region modules, services…
<missing>
Scripter
Developer
Scripter
The subject of presentation is an attempt to discuss an ability to
create a missing link.
8. Virtual application
Scripter set of tools could be extended
Region modules
OSSL API
Various .Net languages (Xengine)
ModInvoke
…
…when do we need to stop?
Dynamic virtual environment - a three-dimensional multi-user environment
where the minimum program unit – module of such environment is an object
of this environment.
Virtual application - a program unit of virtual environment, fully independent
from client-server realization and network protocol application, which
have a full access to programming language standard library, an ability
to use dependencies (assemblies) and full access to all client and server
methods.
Analogy: a default application in modern OS.
9. Requirements for VA
Modular client (client-side plugins)
Possibility to use full .Net language in scripts
(classes, events, etc.)
Possibility to use precompiled assemblies
Reuse as much code as possible (client – server –
libOMV)
12. Basic C#
//c#o
namespace SecondLife
{
public class Script :
OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass
{
public Script():base(){}
public void default_event_state_entry()
{
llSay(0,"Hello,Avatar!");
}
public void default_event_touch_start(LSL_Integer count)
{
llSay(0,"Touched.");
}
}
}
13. C# classes
//c#o
namespace SecondLife
{
class Test
{
OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass main_script;
int i;
public Test(OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass ms){i=0; main_script=ms;}
public void Add(){i=i+1;main_script.llSay(0,"I changed!");}
public int Get() {return i;}
};
public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass
{
Test t;
public Script():base(){}
public void default_event_state_entry()
{
llSay(0,"Hello,Avatar!");
t=new Test(this);
}
public void default_event_touch_start(LSL_Integer count)
{
t.Add();
llSay(0,"Touched."+t.Get());
}
}
}
14. Code editor problem
Viewer code editor is bad for C#
Syntax highlighting, autocomplete, etc.
Xamarin studio integration
How it works
○ We have project template and necessary .dll’s on client side
○ Client creates temporary project and open it by Xamarin
15. “Wrapper” classes
namespace SecondLife
{
public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass
{
public Script():base(){}
CSHost host;
public override void InitGlobals()
{
host=getHost();
}
public void default_event_state_entry()
{
llSay(0,"Hello,Avatar!");
}
public void default_event_touch_start(LSL_Integer count)
{
host.Color=new LSL_Vector(1,0,0);
llSay(0,"Touched.");
}
}
}
• A set of “build-in” classes – “standard library” (with LSL/OSSL/LS)
•Not serializable, so we need InitGlobals()
16. New asset types
“Generic file”
Useful for generic file exchange. Default inventory function –
download.
Assembly
Precompiled script. Starts in prim inventory.
Could be used as reference in default script or another assembly (not finished)
19. Embedding Mono
Minimal runtime
~10 mb
One main “entry point” assembly
Main assembly defines the interface for
plugins
Reusing libOMV
public interface ITrialityPlugin
{
void RegisterPlugin();
string GetName();
void RunPlugin();
}
20. Main plugin problems
Message system
Handle in and out SL-protocol messages
Possibility to send message
User interface
Get and set the values of UI controls
Handle messages from UI
Add new controls
Client internals
21. Message system
Works like libOMV GridProxy
public void RegisterPlugin()
{
Triality.AddDelegate (PacketType.ChatFromSimulator, TestChatDelegate); //subscribe to in packet
Triality.AddOutDelegate (PacketType.ChatFromViewer, TestOutChatDelegate); //subscribe to out packet
}
public bool TestOutChatDelegate(Packet p)
{
ChatFromViewerPacket cp = (ChatFromViewerPacket)p;
string chatstr = System.Text.Encoding.UTF8.GetString (cp.ChatData.Message);
Triality.debug_output("______CHAT OUT PACKET:"+chatstr);
return true; //packet passed to server
}
public bool TestChatDelegate(Packet p)
{
ChatFromSimulatorPacket cp = (ChatFromSimulatorPacket)p;
string chatstr = System.Text.Encoding.UTF8.GetString (cp.ChatData.Message);
Triality.debug_output("______CHAT PACKET:"+chatstr);
return true; //packet passed to viewer
}
27. What we have
Client plugins
Server assemblies
Not a virtual application (different
projects)
28. Generic client/server calls
public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass
{
CSClient test;
public Script():base(){}
public override void InitGlobals()
{
test=getAllClients(); //could be by UUID
}
public void default_event_touch_start(LSL_Integer count)
{
test.SendChat("TEST STRING"); //client method call
llSay(0,"Touched.");
}
29. Direct client/server calls
Client:
Server:
foreach (KeyValuePair<UUID,string> kv in Triality.mRegisteredSceneScripts)
{
Triality.debug_output (“Registered server script:" + kv.Value); //kv.Value – script registration name
Triality.SendDirectMessageToScript (kv.Key, "TEST DIRECT MESSAGE");
}
public override void InitGlobals()
{
osRegisterCSScript ("MessageTest"); //random UUID; could be predefined
}
public void default_event_message_from_client_plugin (LSL_Key client, LSL_String msg)
{
llSay(0,"Message from client plugin:"+msg);
}
30. Future
Xamarin/Visual Studio plugin
UI designer and code generation
Project types: client plugin, server assembly,
full VA
Testing environment
Use attributes for remote calls code
generation
On both (client and server sides)
Virtual application.
33. Conclusions
Modular client
Full-scale server scripting language
“Standard library” for client and server
Xamarin/VS as a developer environment
In the future – virtual application
Possibility to distribute client plugins and
server assemblies on commercial base
35. English language for
aviation
2009, Aeroflot – Russian airlines
Agent based English language training
for cabin crew
Main features
Using of bots (agents) for role-play games and demonstration of typical
situations
XML scenarios of bots behavior, and visual designer for them
An ability to take control of every bot (by teacher)
Integration with Moodle, Airbus LMS, and internal ERP services
Text-to-Speech (voices for bots)
…..
Could be realized by standard tools (LSL/server modules), but really
difficult.