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(); }
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(); }
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); }
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); }
void IBinderProvider.AssignBinder(ISoulBinder binder) { _BinderProvider.AssignBinder(binder); }