aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/RemoteServer/RemoteServer.cs
blob: 1a528c843bbffab9b3eb5f48a525d472f0cfd568 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

namespace OpenSim.Region.ScriptEngine.RemoteServer
{
    class RemoteServer
    {
        // Handles connections to servers
        // Create and returns server object

        public OpenSim.Grid.ScriptServer.RemotingObject Connect(string hostname, int port)
        {
            // Create a channel for communicating w/ the remote object
            // Notice no port is specified on the client
            TcpChannel chan = new TcpChannel();
            ChannelServices.RegisterChannel(chan, true);

            // Create an instance of the remote object
            OpenSim.Grid.ScriptServer.RemotingObject obj = (OpenSim.Grid.ScriptServer.RemotingObject)Activator.GetObject(
                typeof(OpenSim.Grid.ScriptServer.RemotingObject),
                "tcp://" + hostname + ":" + port + "/DotNetEngine");

            // Use the object
            if (obj.Equals(null))
            {
                System.Console.WriteLine("Error: unable to locate server");
            }
            else
            {
                return obj;
            }
            return null;

        }
    }
}