示例#1
0
        public void Send <T>(Player player, byte system, byte type, T data)
        {
            var json = Serialize(system, type, data);

            var connection = _socketRepository.GetConnection(player.Id);

            if (connection?.Stream != null)
            {
                _webSocketCore.Send(connection.Stream, json);
            }
        }
示例#2
0
        public void Report(Fight fight, List <FighterAction> actions)
        {
            var response = new CombatReportResponse();

            response.Actions   = actions;
            response.NextRound = fight.NextRound.ToUnixTimeMilliseconds();

            foreach (var playerId in fight.GetAllPlayerIds())
            {
                var connection = _socketRepository.GetConnection(playerId);
                _messageService.Send(
                    connection,
                    SystemTypes.Combat,
                    SystemTypes.CombatTypes.Report,
                    response);
            }
        }
示例#3
0
        private void SendPlayerInformation(Player player, ClientConnection connection, string token)
        {
            var currentConnection = _socketRepository.GetConnection(player.Id);

            if (currentConnection != null)
            {
                _loginSender.Logout(currentConnection);
            }

            _socketRepository.AddConnection(player.Id, connection);
            //_positionRepository.SetPlayerPosition(player, player.Node);

            _loginSender.Success(player, token);
            _joinSender.Join(player);
            _locationSender.Update(player.Node);
        }