Exemplo n.º 1
0
        private async Task AddInstance()
        {
            var name = "peer" + i++;
            //var domain = AppDomain.CreateDomain(name, null, AppDomain.CurrentDomain.BaseDirectory, "", true);
            //var path = domain.BaseDirectory;
            var proxy = new PeerProxy();
            //var proxy = (PeerProxy)domain.CreateInstanceAndUnwrap(typeof(PeerProxy).Assembly.FullName, typeof(PeerProxy).FullName);
            var peer = new Peer { Proxy = proxy };
            lock (_peers)
            {
                _peers.Add(peer);
            }

            proxy.Stopped = () =>
            {
                _peers.Remove(peer);
            };

            await proxy.Start(name, _apiEndpoint, _accountId, _app, _sceneId, true);

        }
Exemplo n.º 2
0
        public async Task Start(string name, string apiEndpoint,string accountId, string app, string scene, bool canAttack)
        {
            try
            {
                _peer = new Peer(name,apiEndpoint, accountId, app, scene,canAttack);
                _peer.Stopped = () =>{
                    var stopped = Stopped;
                    if(stopped !=null)
                    {
                        stopped();
                    }
                };
                await _peer.Start();
                
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
                throw;
            }


        }