public Task Start(Stormancer.Client client)
        {
            if (!IsRunning)
            {
                _client = client;

                return Initialize();


            }
            return Task.FromResult(true);
        }
 public void Log(Stormancer.Diagnostics.LogLevel logLevel, string category, string message, object context = null)
 {
     var temp = new StormancerEditorLog();
     temp.logLevel = logLevel.ToString();
     temp.message = message;
     _clientVM.log.log.Enqueue(temp);
     foreach (StormancerSceneViewModel s in _clientVM.scenes.Values)
     {
         if (category == s.scene.Id)
             s.log.log.Enqueue(temp);
     }
     _innerLogger.Log(logLevel, category, message, context);
 }
        internal Scene(IConnection connection, Client client, string id, string token, Stormancer.Dto.SceneInfosDto dto, PluginBuildContext pluginCtx, StormancerResolver res)
        {
            Id = id;
            this._peer = connection;
            _token = token;
            _client = client;
            _metadata = dto.Metadata;
            _pluginCtx = pluginCtx;
            DependencyResolver = new StormancerResolver(res);

            foreach (var route in dto.Routes)
            {
                _remoteRoutesMap.Add(route.Name, new Route(this, route.Name, route.Metadata) { Handle = route.Handle });
            }
        }
 public WebSocketClientTransport(Stormancer.Diagnostics.ILogger logger)
 {
     this._logger = logger;
 }
Beispiel #5
0
        private async Task OnConnected(IScenePeerClient client)
        {
            var pInfos = PlayerInfos.FromPeer(client);

            var player = new Player(pInfos, client.Id);

            _players.AddOrUpdate(client.Id, player, (id, old) => player);

            Ship ship = null;
            if (!player.IsObserver)
            {
                ship = CreateShip(player);
                player.ShipId = ship.id;
                _ships.AddOrUpdate(ship.id, ship, (id, old) => ship);

                var dto = new ShipCreatedDto { timestamp = _scene.GetComponent<IEnvironment>().Clock, id = ship.id, team = ship.team, x = ship.x, y = ship.y, rot = ship.rot, weapons = ship.weapons, status = ship.Status };
                var data = new[] { dto };

                client.Send("ship.me", s => client.Serializer().Serialize(data, s), PacketPriority.MEDIUM_PRIORITY, PacketReliability.RELIABLE);

                _scene.Broadcast("ship.add", data, PacketPriority.MEDIUM_PRIORITY, PacketReliability.RELIABLE);

            }

            // Send ships to new client
            var shipsToSend = new List<ShipCreatedDto>();
            foreach (var s in _ships.Values.ToArray())
            {
                var dto = new ShipCreatedDto { timestamp = _scene.GetComponent<IEnvironment>().Clock, id = s.id, team = s.team, x = s.x, y = s.y, rot = s.rot, weapons = s.weapons, status = s.Status };
                if (ship == null || ship.id != s.id)
                {
                    shipsToSend.Add(dto);
                }
            }
            client.Send("ship.add", stream =>
            {
                client.Serializer().Serialize(shipsToSend, stream);
            }, PacketPriority.MEDIUM_PRIORITY, PacketReliability.RELIABLE);

            if (ship != null)
            {
                await Task.Delay(1000);
                ship.UpdateStatus(ShipStatus.InGame);
            }

            _scene.GetComponent<ILogger>().Info("gameScene", "Added ship");

            StartUpdateLoop();
        }
Beispiel #6
0
		public void Log(Stormancer.Diagnostics.LogLevel logLevel, string category, string message, object context = null)
        {
            UnityEngine.Debug.Log(logLevel.ToString() + ": " + category + ": " + message);
        }
Beispiel #7
0
		public void Log(Stormancer.Diagnostics.LogLevel logLevel, string category, string message, object context = null)
		{
			
		}