Ejemplo n.º 1
0
        public EditorServer(RemotingManager remotingManager, HostEndPoint endPoint)
            : base(remotingManager, endPoint)
        {
            UserManager = new UserManager();
            //serviceManager.AddImplementation<IUserManager>(UserManager);
            //var serviceManager = remotingManager.ServiceManager;
            //serviceManager.

            ProjectManager = new ProjectManager();
            //serviceManager.AddImplementation<IProjectManager>(ProjectManager);
        }
Ejemplo n.º 2
0
        public Server(RemotingManager remotingManager, HostEndPoint endPoint)
            : base(remotingManager)
        {
            // TODO: remove this from here
            //Flood.Network.NetworkInitialize();

            var server = new HostServer();
            host = server;

            var details = new HostConnectionDetails()
            {
                Address = endPoint.Address,
                Port = endPoint.Port,
                ChannelCount = ChannelCount
            };

            server.SessionPacket += OnPacket;
            server.CreateSocket(details);
        }
Ejemplo n.º 3
0
        public void TestServiceAsyncCall()
        {
            const ushort ServerPort = 13337;

            var moduleManager = new ModuleManager();
            var remotingManager = new RemotingManager(moduleManager);
            moduleManager.Init(remotingManager.ServiceManager);

            var endPoint = new HostEndPoint("localhost", ServerPort);

            // Start the server and setup our service.
            var server = new Server(remotingManager, endPoint);
            var serverThread = new Thread(Process);
            serverThread.Start(server);

            // Start the client and connect to the service.
            var client = new Client(remotingManager);
            var clientThread = new Thread(Process);
            clientThread.Start(client);

            var connectTask = client.Connect(endPoint);
            connectTask.Wait();
            Assert.IsTrue(connectTask.Result);

            var service = new ServiceTest();
            var serviceImpl = server.RemotingManager.ServiceManager.GetCreateImplementation<IServiceTest>(service);

            var serviceProxy = client.RemotingManager.ServiceManager.GetService<IServiceTest>(new SessionRemotingPeer(client.Session), serviceImpl.LocalId);
            var pingTask = serviceProxy.Ping();

            Assert.IsTrue(pingTask.Wait(1000));
            Assert.AreEqual("Pong", pingTask.Result);

            serverThread.Abort();
            clientThread.Abort();
         }
Ejemplo n.º 4
0
        public async Task<bool> Connect(HostEndPoint endPoint, int timeout = 1000)
        {
            // TODO: remove this from here.
            //Flood.Network.NetworkInitialize();

            var client = new HostClient();
            host = client;

            var tcs = new TaskCompletionSource<bool>();

            var session = client.Session;
            session.StateChange += state =>
                                       {
                                           if (state == SessionState.Open)
                                               tcs.SetResult(true);
                                       };

            var details = new HostConnectionDetails()
            {
                Address = endPoint.Address,
                Port = endPoint.Port,
                ChannelCount = ChannelCount
            };

            client.Connect(details);

            // Wait for task somewhere else
            if (await Task.WhenAny(tcs.Task, Task.Delay(timeout)) != tcs.Task)
                return false;

            client.SessionPacket += OnPacket;

            Log.Info("Client connected with session!");
            return true;
        }