Exemplo n.º 1
0
        public void ServiceTest()
        {
            Stream      serverPeerStream = new Regulus.Remote.Standalone.Stream();
            IStreamable serverStream     = serverPeerStream;
            IStreamable clientStream     = new ReverseStream(serverPeerStream);

            IBinderProvider entry = NSubstitute.Substitute.For <IBinderProvider>();
            IGpiA           gpia  = new SoulGpiA();

            entry.AssignBinder(NSubstitute.Arg.Do <IBinder>(binder => binder.Bind <IGpiA>(gpia)), NSubstitute.Arg.Any <object>());

            Serialization.ISerializer serializer = new Regulus.Serialization.Dynamic.Serializer();
            IProtocol protocol = ProtocolHelper.CreateProtocol(serializer);

            Soul.IService service   = new Regulus.Remote.Soul.Service(entry, protocol);
            IAgent        agent     = new Regulus.Remote.Ghost.Agent(protocol) as Ghost.IAgent;
            IGpiA         ghostGpia = null;


            service.Join(serverStream);
            agent.Start(clientStream);
            agent.QueryNotifier <IGpiA>().Supply += gpi => ghostGpia = gpi;

            while (ghostGpia == null)
            {
                agent.Update();
            }

            agent.Stop();
            service.Leave(serverStream);

            IDisposable disposable = service;

            disposable.Dispose();
        }
Exemplo n.º 2
0
 public Service(IBinderProvider entry, IProtocol protocol)
 {
     _Users             = new System.Collections.Generic.List <User>();
     this._Entry        = entry;
     this._Protocol     = protocol;
     _Updater           = new Utility.Updater();
     _Updater.AddEvent += (user) => _Entry.AssignBinder(((User)user).Binder, ((User)user).State);
     _ThreadUpdater     = new ThreadUpdater(_Update);
     _ThreadUpdater.Start();
 }
Exemplo n.º 3
0
        void IService.Join(Network.IStreamable stream, object state)
        {
            User user = new User(stream, _Protocol);

            lock (_Users)
            {
                _Users.Add(user);
            }
            user.Launch();
            _Entry.AssignBinder(user.Binder, state);
        }
Exemplo n.º 4
0
        public void Test()
        {
            IBinderProvider entry = NSubstitute.Substitute.For <IBinderProvider>();
            IGpiA           gpia  = new SoulGpiA();
            bool            bind  = false;

            entry.AssignBinder(NSubstitute.Arg.Do <IBinder>(binder =>
            {
                bind = true;
                binder.Bind <IGpiA>(gpia);
            }), NSubstitute.Arg.Any <object>());

            Serialization.ISerializer serializer = new Regulus.Serialization.Dynamic.Serializer();
            IProtocol protocol = ProtocolHelper.CreateProtocol(serializer);

            _TestService(entry, ref bind, protocol);
        }
Exemplo n.º 5
0
 void IBinderProvider.AssignBinder(ISoulBinder binder)
 {
     _BinderProvider.AssignBinder(binder);
 }